@@ -15,6 +15,10 @@ default_stages: [
15
15
ci :
16
16
autofix_prs : false
17
17
repos :
18
+ - repo : https://github.com/charliermarsh/ruff-pre-commit
19
+ rev : v0.0.215
20
+ hooks :
21
+ - id : ruff
18
22
- repo : https://github.com/MarcoGorelli/absolufy-imports
19
23
rev : v0.3.1
20
24
hooks :
34
38
types_or : [python, rst, markdown]
35
39
additional_dependencies : [tomli]
36
40
- repo : https://github.com/MarcoGorelli/cython-lint
37
- rev : v0.9 .1
41
+ rev : v0.10 .1
38
42
hooks :
39
43
- id : cython-lint
40
44
- id : double-quote-cython-strings
@@ -63,25 +67,16 @@ repos:
63
67
' --extensions=c,h' ,
64
68
' --headers=h' ,
65
69
--recursive,
66
- ' --filter=-readability/casting,-runtime/int,-build/include_subdir'
70
+ --linelength=88,
71
+ ' --filter=-readability/casting,-runtime/int,-build/include_subdir,-readability/fn_size'
67
72
]
68
- - repo : https://github.com/PyCQA/flake8
69
- rev : 6.0.0
70
- hooks :
71
- - id : flake8
72
- # Need to patch os.remove rule in pandas-dev-flaker
73
- exclude : ^ci/fix_wheels.py
74
- additional_dependencies : &flake8_dependencies
75
- - flake8==6.0.0
76
- - flake8-bugbear==22.7.1
77
- - pandas-dev-flaker==0.5.0
78
73
- repo : https://github.com/pycqa/pylint
79
- rev : v2.15.6
74
+ rev : v2.15.9
80
75
hooks :
81
76
- id : pylint
82
77
stages : [manual]
83
78
- repo : https://github.com/pycqa/pylint
84
- rev : v2.15.6
79
+ rev : v2.15.9
85
80
hooks :
86
81
- id : pylint
87
82
alias : redefined-outer-name
@@ -94,15 +89,14 @@ repos:
94
89
|^pandas/util/_test_decorators\.py # keep excluded
95
90
|^pandas/_version\.py # keep excluded
96
91
|^pandas/conftest\.py # keep excluded
97
- |^pandas/core/generic\.py
98
92
args : [--disable=all, --enable=redefined-outer-name]
99
93
stages : [manual]
100
94
- repo : https://github.com/PyCQA/isort
101
- rev : 5.10.1
95
+ rev : 5.11.4
102
96
hooks :
103
97
- id : isort
104
98
- repo : https://github.com/asottile/pyupgrade
105
- rev : v3.2.2
99
+ rev : v3.3.1
106
100
hooks :
107
101
- id : pyupgrade
108
102
args : [--py38-plus]
@@ -120,12 +114,6 @@ repos:
120
114
rev : v0.6.7
121
115
hooks :
122
116
- id : sphinx-lint
123
- - repo : https://github.com/asottile/yesqa
124
- rev : v1.4.0
125
- hooks :
126
- - id : yesqa
127
- additional_dependencies : *flake8_dependencies
128
- stages : [manual]
129
117
- repo : local
130
118
hooks :
131
119
# NOTE: we make `black` a local hook because if it's installed from
@@ -183,6 +171,21 @@ repos:
183
171
types : [rst]
184
172
args : [--filename=*.rst]
185
173
additional_dependencies : [flake8-rst==0.7.0, flake8==3.7.9]
174
+ - id : inconsistent-namespace-usage
175
+ name : ' Check for inconsistent use of pandas namespace'
176
+ entry : python scripts/check_for_inconsistent_pandas_namespace.py
177
+ exclude : ^pandas/core/interchange/
178
+ language : python
179
+ types : [python]
180
+ - id : no-os-remove
181
+ name : Check code for instances of os.remove
182
+ entry : os\.remove
183
+ language : pygrep
184
+ types : [python]
185
+ files : ^pandas/tests/
186
+ exclude : |
187
+ (?x)^
188
+ pandas/tests/io/pytables/test_store\.py$
186
189
- id : unwanted-patterns
187
190
name : Unwanted patterns
188
191
language : pygrep
@@ -192,6 +195,20 @@ repos:
192
195
\#\ type:\ (?!ignore)
193
196
|\#\ type:\s?ignore(?!\[)
194
197
198
+ # foo._class__ instead of type(foo)
199
+ |\.__class__
200
+
201
+ # np.bool/np.object instead of np.bool_/np.object_
202
+ |np\.bool[^_8`]
203
+ |np\.object[^_8`]
204
+
205
+ # imports from collections.abc instead of `from collections import abc`
206
+ |from\ collections\.abc\ import
207
+
208
+ # Numpy
209
+ |from\ numpy\ import\ random
210
+ |from\ numpy\.random\ import
211
+
195
212
# Incorrect code-block / IPython directives
196
213
|\.\.\ code-block\ ::
197
214
|\.\.\ ipython\ ::
@@ -200,7 +217,17 @@ repos:
200
217
201
218
# Check for deprecated messages without sphinx directive
202
219
|(DEPRECATED|DEPRECATE|Deprecated)(:|,|\.)
220
+
221
+ # {foo!r} instead of {repr(foo)}
222
+ |!r}
223
+
224
+ # builtin filter function
225
+ |(?<!def)[\(\s]filter\(
226
+
227
+ # exec
228
+ |[^a-zA-Z0-9_]exec\(
203
229
types_or : [python, cython, rst]
230
+ exclude : ^doc/source/development/code_style\.rst # contains examples of patterns to avoid
204
231
- id : cython-casting
205
232
name : Check Cython casting is `<type>obj`, not `<type> obj`
206
233
language : pygrep
@@ -231,26 +258,103 @@ repos:
231
258
files : ^pandas/tests/extension/base
232
259
types : [python]
233
260
exclude : ^pandas/tests/extension/base/base\.py
261
+ - id : unwanted-patterns-in-tests
262
+ name : Unwanted patterns in tests
263
+ language : pygrep
264
+ entry : |
265
+ (?x)
266
+ # pytest.xfail instead of pytest.mark.xfail
267
+ pytest\.xfail
268
+
269
+ # imports from pandas._testing instead of `import pandas._testing as tm`
270
+ |from\ pandas\._testing\ import
271
+ |from\ pandas\ import\ _testing\ as\ tm
272
+
273
+ # No direct imports from conftest
274
+ |conftest\ import
275
+ |import\ conftest
276
+
277
+ # pandas.testing instead of tm
278
+ |pd\.testing\.
279
+
280
+ # pd.api.types instead of from pandas.api.types import ...
281
+ |(pd|pandas)\.api\.types\.
282
+
283
+ # np.testing, np.array_equal
284
+ |(numpy|np)(\.testing|\.array_equal)
285
+
286
+ # unittest.mock (use pytest builtin monkeypatch fixture instead)
287
+ |(unittest(\.| import )mock|mock\.Mock\(\)|mock\.patch)
288
+
289
+ # pytest raises without context
290
+ |\s\ pytest.raises
291
+
292
+ # pytest.warns (use tm.assert_produces_warning instead)
293
+ |pytest\.warns
294
+ files : ^pandas/tests/
295
+ types_or : [python, cython, rst]
296
+ - id : unwanted-patterns-in-ea-tests
297
+ name : Unwanted patterns in EA tests
298
+ language : pygrep
299
+ entry : |
300
+ (?x)
301
+ tm.assert_(series|frame)_equal
302
+ files : ^pandas/tests/extension/base/
303
+ exclude : ^pandas/tests/extension/base/base\.py$
304
+ types_or : [python, cython, rst]
305
+ - id : unwanted-patterns-in-cython
306
+ name : Unwanted patterns in Cython code
307
+ language : pygrep
308
+ entry : |
309
+ (?x)
310
+ # `<type>obj` as opposed to `<type> obj`
311
+ [a-zA-Z0-9*]>[ ]
312
+ types : [cython]
234
313
- id : pip-to-conda
235
314
name : Generate pip dependency from conda
236
315
language : python
237
316
entry : python scripts/generate_pip_deps_from_conda.py
238
317
files : ^(environment.yml|requirements-dev.txt)$
239
318
pass_filenames : false
240
319
additional_dependencies : [pyyaml, toml]
241
- - id : sync-flake8-versions
242
- name : Check flake8 version is synced across flake8, yesqa, and environment.yml
243
- language : python
244
- entry : python scripts/sync_flake8_versions.py
245
- files : ^(\.pre-commit-config\.yaml|environment\.yml)$
246
- pass_filenames : false
247
- additional_dependencies : [pyyaml, toml]
248
320
- id : title-capitalization
249
321
name : Validate correct capitalization among titles in documentation
250
322
entry : python scripts/validate_rst_title_capitalization.py
251
323
language : python
252
324
types : [rst]
253
325
files : ^doc/source/(development|reference)/
326
+ - id : unwanted-patterns-bare-pytest-raises
327
+ name : Check for use of bare pytest raises
328
+ language : python
329
+ entry : python scripts/validate_unwanted_patterns.py --validation-type="bare_pytest_raises"
330
+ types : [python]
331
+ files : ^pandas/tests/
332
+ exclude : ^pandas/tests/extension/
333
+ - id : unwanted-patterns-private-function-across-module
334
+ name : Check for use of private functions across modules
335
+ language : python
336
+ entry : python scripts/validate_unwanted_patterns.py --validation-type="private_function_across_module"
337
+ types : [python]
338
+ exclude : ^(asv_bench|pandas/tests|doc)/
339
+ - id : unwanted-patterns-private-import-across-module
340
+ name : Check for import of private attributes across modules
341
+ language : python
342
+ entry : python scripts/validate_unwanted_patterns.py --validation-type="private_import_across_module"
343
+ types : [python]
344
+ exclude : |
345
+ (?x)
346
+ ^(asv_bench|pandas/tests|doc)/
347
+ |scripts/validate_min_versions_in_sync\.py$
348
+ - id : unwanted-patterns-strings-to-concatenate
349
+ name : Check for use of not concatenated strings
350
+ language : python
351
+ entry : python scripts/validate_unwanted_patterns.py --validation-type="strings_to_concatenate"
352
+ types_or : [python, cython]
353
+ - id : unwanted-patterns-strings-with-misplaced-whitespace
354
+ name : Check for strings with misplaced spaces
355
+ language : python
356
+ entry : python scripts/validate_unwanted_patterns.py --validation-type="strings_with_wrong_placed_whitespace"
357
+ types_or : [python, cython]
254
358
- id : use-pd_array-in-core
255
359
name : Import pandas.array as pd_array in core
256
360
language : python
0 commit comments