Skip to content

Commit 9208a35

Browse files
authored
reorder pre-commit-config and normalize id names (#40277)
1 parent 68dc4c2 commit 9208a35

File tree

1 file changed

+112
-113
lines changed

1 file changed

+112
-113
lines changed

.pre-commit-config.yaml

+112-113
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,28 @@
11
minimum_pre_commit_version: 2.9.2
22
exclude: ^LICENSES/|\.(html|csv|svg)$
33
repos:
4+
- repo: https://github.com/MarcoGorelli/absolufy-imports
5+
rev: v0.2.1
6+
hooks:
7+
- id: absolufy-imports
8+
files: ^pandas/
49
- repo: https://github.com/python/black
510
rev: 20.8b1
611
hooks:
712
- id: black
13+
- repo: https://github.com/codespell-project/codespell
14+
rev: v2.0.0
15+
hooks:
16+
- id: codespell
17+
types_or: [python, rst, markdown]
18+
files: ^pandas/
19+
exclude: ^pandas/tests/
20+
- repo: https://github.com/pre-commit/pre-commit-hooks
21+
rev: v3.4.0
22+
hooks:
23+
- id: end-of-file-fixer
24+
exclude: \.txt$
25+
- id: trailing-whitespace
826
- repo: https://gitlab.com/pycqa/flake8
927
rev: 3.8.4
1028
hooks:
@@ -23,6 +41,10 @@ repos:
2341
rev: 5.7.0
2442
hooks:
2543
- id: isort
44+
- repo: https://github.com/MarcoGorelli/no-string-hints
45+
rev: v0.1.7
46+
hooks:
47+
- id: no-string-hints
2648
- repo: https://github.com/asottile/pyupgrade
2749
rev: v2.10.0
2850
hooks:
@@ -38,16 +60,12 @@ repos:
3860
- id: rst-inline-touching-normal
3961
types: [text] # overwrite types: [rst]
4062
types_or: [python, rst]
63+
- repo: https://github.com/asottile/yesqa
64+
rev: v1.2.2
65+
hooks:
66+
- id: yesqa
4167
- repo: local
4268
hooks:
43-
- id: pip_to_conda
44-
name: Generate pip dependency from conda
45-
description: This hook checks if the conda environment.yml and requirements-dev.txt are equal
46-
language: python
47-
entry: python scripts/generate_pip_deps_from_conda.py
48-
files: ^(environment.yml|requirements-dev.txt)$
49-
pass_filenames: false
50-
additional_dependencies: [pyyaml]
5169
- id: flake8-rst
5270
name: flake8-rst
5371
description: Run flake8 on code snippets in docstrings or RST files
@@ -56,6 +74,40 @@ repos:
5674
types: [rst]
5775
args: [--filename=*.rst]
5876
additional_dependencies: [flake8-rst==0.7.0, flake8==3.7.9]
77+
- id: frame-or-series-union
78+
name: Check for use of Union[Series, DataFrame] instead of FrameOrSeriesUnion alias
79+
entry: Union\[.*(Series,.*DataFrame|DataFrame,.*Series).*\]
80+
language: pygrep
81+
types: [python]
82+
exclude: ^pandas/_typing\.py$
83+
- id: inconsistent-namespace-usage
84+
name: 'Check for inconsistent use of pandas namespace in tests'
85+
entry: python scripts/check_for_inconsistent_pandas_namespace.py
86+
language: python
87+
types: [python]
88+
files: ^pandas/tests/frame/
89+
- id: incorrect-code-directives
90+
name: Check for incorrect code block or IPython directives
91+
language: pygrep
92+
entry: (\.\. code-block ::|\.\. ipython ::)
93+
types_or: [python, cython, rst]
94+
- id: no-os-remove
95+
name: Check code for instances of os.remove
96+
entry: os\.remove
97+
language: pygrep
98+
types: [python]
99+
files: ^pandas/tests/
100+
exclude: |
101+
(?x)^
102+
pandas/tests/io/excel/test_writers\.py
103+
|pandas/tests/io/pytables/common\.py
104+
|pandas/tests/io/pytables/test_store\.py$
105+
- id: no-pandas-api-types
106+
name: Check code for instances of pd.api.types
107+
entry: (pd|pandas)\.api\.types\.
108+
language: pygrep
109+
types: [python]
110+
files: ^pandas/tests/
59111
- id: non-standard-imports
60112
name: Check for non-standard imports
61113
language: pygrep
@@ -67,17 +119,6 @@ repos:
67119
68120
# Check for imports from collections.abc instead of `from collections import abc`
69121
|from\ collections\.abc\ import
70-
71-
- id: non-standard-numpy.random-related-imports
72-
name: Check for non-standard numpy.random-related imports excluding pandas/_testing.py
73-
language: pygrep
74-
exclude: pandas/_testing.py
75-
entry: |
76-
(?x)
77-
# Check for imports from np.random.<method> instead of `from numpy import random` or `from numpy.random import <method>`
78-
from\ numpy\ import\ random
79-
|from\ numpy.random\ import
80-
types: [python]
81122
- id: non-standard-imports-in-tests
82123
name: Check for non-standard imports in test suite
83124
language: pygrep
@@ -95,62 +136,79 @@ repos:
95136
|pd\.testing\.
96137
types: [python]
97138
files: ^pandas/tests/
98-
- id: incorrect-code-directives
99-
name: Check for incorrect code block or IPython directives
139+
- id: non-standard-numpy-random-related-imports
140+
name: Check for non-standard numpy.random-related imports excluding pandas/_testing.py
141+
language: pygrep
142+
exclude: pandas/_testing.py
143+
entry: |
144+
(?x)
145+
# Check for imports from np.random.<method> instead of `from numpy import random` or `from numpy.random import <method>`
146+
from\ numpy\ import\ random
147+
|from\ numpy.random\ import
148+
types: [python]
149+
- id: np-bool
150+
name: Check for use of np.bool instead of np.bool_
151+
entry: np\.bool[^_8]
100152
language: pygrep
101-
entry: (\.\. code-block ::|\.\. ipython ::)
102153
types_or: [python, cython, rst]
103-
- id: unwanted-patterns-strings-to-concatenate
104-
name: Check for use of not concatenated strings
154+
- id: np-object
155+
name: Check for use of np.object instead of np.object_
156+
entry: np\.object[^_8]
157+
language: pygrep
158+
types_or: [python, cython, rst]
159+
- id: pip-to-conda
160+
name: Generate pip dependency from conda
161+
description: This hook checks if the conda environment.yml and requirements-dev.txt are equal
105162
language: python
106-
entry: python scripts/validate_unwanted_patterns.py --validation-type="strings_to_concatenate"
107-
types_or: [python, cython]
108-
- id: unwanted-patterns-strings-with-wrong-placed-whitespace
109-
name: Check for strings with wrong placed spaces
163+
entry: python scripts/generate_pip_deps_from_conda.py
164+
files: ^(environment.yml|requirements-dev.txt)$
165+
pass_filenames: false
166+
additional_dependencies: [pyyaml]
167+
- id: title-capitalization
168+
name: Validate correct capitalization among titles in documentation
169+
entry: python scripts/validate_rst_title_capitalization.py
110170
language: python
111-
entry: python scripts/validate_unwanted_patterns.py --validation-type="strings_with_wrong_placed_whitespace"
171+
types: [rst]
172+
files: ^doc/source/(development|reference)/
173+
- id: type-not-class
174+
name: Check for use of foo.__class__ instead of type(foo)
175+
entry: \.__class__
176+
language: pygrep
112177
types_or: [python, cython]
113-
- id: unwanted-patterns-private-import-across-module
114-
name: Check for import of private attributes across modules
178+
- id: unwanted-patterns-bare-pytest-raises
179+
name: Check for use of bare pytest raises
115180
language: python
116-
entry: python scripts/validate_unwanted_patterns.py --validation-type="private_import_across_module"
181+
entry: python scripts/validate_unwanted_patterns.py --validation-type="bare_pytest_raises"
117182
types: [python]
118-
exclude: ^(asv_bench|pandas/tests|doc)/
183+
files: ^pandas/tests/
184+
exclude: ^pandas/tests/extension/
119185
- id: unwanted-patterns-private-function-across-module
120186
name: Check for use of private functions across modules
121187
language: python
122188
entry: python scripts/validate_unwanted_patterns.py --validation-type="private_function_across_module"
123189
types: [python]
124190
exclude: ^(asv_bench|pandas/tests|doc)/
125-
- id: unwanted-patterns-bare-pytest-raises
126-
name: Check for use of bare pytest raises
191+
- id: unwanted-patterns-private-import-across-module
192+
name: Check for import of private attributes across modules
127193
language: python
128-
entry: python scripts/validate_unwanted_patterns.py --validation-type="bare_pytest_raises"
194+
entry: python scripts/validate_unwanted_patterns.py --validation-type="private_import_across_module"
129195
types: [python]
130-
files: ^pandas/tests/
131-
exclude: ^pandas/tests/extension/
132-
- id: unwanted-patters-pytest-xfail
196+
exclude: ^(asv_bench|pandas/tests|doc)/
197+
- id: unwanted-patterns-pytest-xfail
133198
name: Check for use of pytest.xfail
134199
entry: pytest\.xfail
135200
language: pygrep
136201
types: [python]
137202
files: ^pandas/tests/
138-
- id: inconsistent-namespace-usage
139-
name: 'Check for inconsistent use of pandas namespace in tests'
140-
entry: python scripts/check_for_inconsistent_pandas_namespace.py
203+
- id: unwanted-patterns-strings-to-concatenate
204+
name: Check for use of not concatenated strings
141205
language: python
142-
types: [python]
143-
files: ^pandas/tests/frame/
144-
- id: FrameOrSeriesUnion
145-
name: Check for use of Union[Series, DataFrame] instead of FrameOrSeriesUnion alias
146-
entry: Union\[.*(Series,.*DataFrame|DataFrame,.*Series).*\]
147-
language: pygrep
148-
types: [python]
149-
exclude: ^pandas/_typing\.py$
150-
- id: type-not-class
151-
name: Check for use of foo.__class__ instead of type(foo)
152-
entry: \.__class__
153-
language: pygrep
206+
entry: python scripts/validate_unwanted_patterns.py --validation-type="strings_to_concatenate"
207+
types_or: [python, cython]
208+
- id: unwanted-patterns-strings-with-wrong-placed-whitespace
209+
name: Check for strings with wrong placed spaces
210+
language: python
211+
entry: python scripts/validate_unwanted_patterns.py --validation-type="strings_with_wrong_placed_whitespace"
154212
types_or: [python, cython]
155213
- id: unwanted-typing
156214
name: Check for outdated annotation syntax and missing error codes
@@ -160,62 +218,3 @@ repos:
160218
|\#\ type:\s?ignore(?!\[)
161219
language: pygrep
162220
types: [python]
163-
- id: np-bool
164-
name: Check for use of np.bool instead of np.bool_
165-
entry: np\.bool[^_8]
166-
language: pygrep
167-
types_or: [python, cython, rst]
168-
- id: np-object
169-
name: Check for use of np.object instead of np.object_
170-
entry: np\.object[^_8]
171-
language: pygrep
172-
types_or: [python, cython, rst]
173-
- id: no-os-remove
174-
name: Check code for instances of os.remove
175-
entry: os\.remove
176-
language: pygrep
177-
types: [python]
178-
files: ^pandas/tests/
179-
exclude: |
180-
(?x)^
181-
pandas/tests/io/excel/test_writers\.py
182-
|pandas/tests/io/pytables/common\.py
183-
|pandas/tests/io/pytables/test_store\.py$
184-
- id: no-pandas-api-types
185-
name: Check code for instances of pd.api.types
186-
entry: (pd|pandas)\.api\.types\.
187-
language: pygrep
188-
types: [python]
189-
files: ^pandas/tests/
190-
- id: title-capitalization
191-
name: Validate correct capitalization among titles in documentation
192-
entry: python scripts/validate_rst_title_capitalization.py
193-
language: python
194-
types: [rst]
195-
files: ^doc/source/(development|reference)/
196-
- repo: https://github.com/asottile/yesqa
197-
rev: v1.2.2
198-
hooks:
199-
- id: yesqa
200-
- repo: https://github.com/pre-commit/pre-commit-hooks
201-
rev: v3.4.0
202-
hooks:
203-
- id: end-of-file-fixer
204-
exclude: \.txt$
205-
- id: trailing-whitespace
206-
- repo: https://github.com/codespell-project/codespell
207-
rev: v2.0.0
208-
hooks:
209-
- id: codespell
210-
types_or: [python, rst, markdown]
211-
files: ^pandas/
212-
exclude: ^pandas/tests/
213-
- repo: https://github.com/MarcoGorelli/no-string-hints
214-
rev: v0.1.7
215-
hooks:
216-
- id: no-string-hints
217-
- repo: https://github.com/MarcoGorelli/absolufy-imports
218-
rev: v0.2.1
219-
hooks:
220-
- id: absolufy-imports
221-
files: ^pandas/

0 commit comments

Comments
 (0)