Skip to content

Commit 9a06485

Browse files
authored
optimise pre-commit (#4208)
1 parent af13e14 commit 9a06485

File tree

3 files changed

+44
-41
lines changed

3 files changed

+44
-41
lines changed

.pre-commit-config.yaml

+24-10
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,18 @@
11
# See https://pre-commit.com for more information
22
# See https://pre-commit.com/hooks.html for more hooks
3+
4+
files: |
5+
(?x)(
6+
noxfile\.py|
7+
setup\.py|
8+
docs\/.+\.py|
9+
lib\/.+\.py
10+
)
11+
minimum_pre_commit_version: 1.21.0
12+
313
repos:
414
- repo: https://github.com/pre-commit/pre-commit-hooks
5-
rev: "v4.0.1"
15+
rev: v4.0.1
616
hooks:
717
# Prevent giant files from being committed.
818
- id: check-added-large-files
@@ -16,27 +26,31 @@ repos:
1626
- id: debug-statements
1727
# Don't commit to main branch.
1828
- id: no-commit-to-branch
29+
1930
- repo: https://github.com/psf/black
20-
rev: "21.6b0"
31+
rev: 21.6b0
2132
hooks:
2233
- id: black
2334
pass_filenames: false
24-
args: ["--config=./pyproject.toml", "--check", "docs", "lib", "noxfile.py", "setup.py"]
35+
args: [--config=./pyproject.toml, --check, .]
36+
2537
- repo: https://github.com/PyCQA/flake8
26-
rev: "3.9.2"
38+
rev: 3.9.2
2739
hooks:
2840
- id: flake8
29-
args: ["--config=./setup.cfg", "docs", "lib", "noxfile.py", "setup.py"]
41+
types: [file, python]
42+
args: [--config=./setup.cfg]
43+
3044
- repo: https://github.com/pycqa/isort
31-
rev: "5.9.1"
45+
rev: 5.9.1
3246
hooks:
3347
- id: isort
34-
# Align CLI usage with other hooks, rather than use isort "src_paths" option
35-
# in the pyproject.toml configuration.
36-
name: isort
37-
args: ["--filter-files", "--check", "docs", "lib", "noxfile.py", "setup.py"]
48+
types: [file, python]
49+
args: [--filter-files, --check]
50+
3851
- repo: https://github.com/asottile/blacken-docs
3952
rev: v1.8.0
4053
hooks:
4154
- id: blacken-docs
55+
types: [file, rst]
4256
additional_dependencies: [black==21.6b0]

lib/iris/tests/test_std_names.py

+17-6
Original file line numberDiff line numberDiff line change
@@ -26,14 +26,25 @@ def test_standard_names(self):
2626

2727
# Check for some known standard names
2828
valid_nameset = set(["air_density", "northward_wind", "wind_speed"])
29-
self.assertTrue(valid_nameset.issubset(keyset), "Known standard name missing from STD_NAMES")
29+
self.assertTrue(
30+
valid_nameset.issubset(keyset),
31+
"Known standard name missing from STD_NAMES",
32+
)
3033

3134
# Check for some invalid standard names
32-
invalid_nameset = set(["invalid_air_density", "invalid_northward_wind",
33-
"invalid_wind_speed",
34-
"stratiform_snowfall_rate"])
35-
self.assertSetEqual(invalid_nameset - keyset, invalid_nameset,
36-
"\nInvalid standard name(s) present in STD_NAMES")
35+
invalid_nameset = set(
36+
[
37+
"invalid_air_density",
38+
"invalid_northward_wind",
39+
"invalid_wind_speed",
40+
"stratiform_snowfall_rate",
41+
]
42+
)
43+
self.assertSetEqual(
44+
invalid_nameset - keyset,
45+
invalid_nameset,
46+
"\nInvalid standard name(s) present in STD_NAMES",
47+
)
3748

3849

3950
if __name__ == "__main__":

pyproject.toml

+3-25
Original file line numberDiff line numberDiff line change
@@ -13,34 +13,18 @@ build-backend = "setuptools.build_meta"
1313
line-length = 79
1414
target-version = ['py37', 'py38']
1515
include = '\.pyi?$'
16-
exclude = '''
17-
16+
extend-exclude = '''
1817
(
1918
/(
20-
\.eggs # exclude a few common directories in the
21-
| \.git # root of the project
22-
| \.hg
23-
| \.mypy_cache
24-
| \.tox
25-
| \.venv
26-
| _build
27-
| buck-out
28-
| build
29-
| compiled_krb
30-
| dist
31-
| etc
32-
| iris_image_test_output
19+
| pyke_rules
3320
| sphinxext
3421
| tools
3522
)/
36-
| gitwash_dumper.py
37-
| _ff_cross_references.py # auto-generated files
38-
| std_names.py
23+
| _ff_cross_references.py
3924
| um_cf_map.py
4025
)
4126
'''
4227

43-
4428
[tool.isort]
4529
force_sort_within_sections = "True"
4630
known_first_party = "iris"
@@ -55,10 +39,4 @@ extend_skip = [
5539
"tools",
5640
]
5741
skip_gitignore = "True"
58-
src_paths = [
59-
"docs",
60-
"lib",
61-
"noxfile.py",
62-
"setup.py",
63-
]
6442
verbose = "False"

0 commit comments

Comments
 (0)