@@ -70,12 +70,9 @@ repos:
70
70
rev : 6.0.0
71
71
hooks :
72
72
- id : flake8
73
- # Need to patch os.remove rule in pandas-dev-flaker
74
- exclude : ^ci/fix_wheels.py
75
73
additional_dependencies : &flake8_dependencies
76
74
- flake8==6.0.0
77
75
- flake8-bugbear==22.7.1
78
- - pandas-dev-flaker==0.5.0
79
76
- repo : https://github.com/pycqa/pylint
80
77
rev : v2.15.6
81
78
hooks :
@@ -184,6 +181,28 @@ repos:
184
181
types : [rst]
185
182
args : [--filename=*.rst]
186
183
additional_dependencies : [flake8-rst==0.7.0, flake8==3.7.9]
184
+ - id : frame-or-series-union
185
+ name : Check for use of Union[Series, DataFrame] instead of FrameOrSeriesUnion alias
186
+ entry : Union\[.*(Series,.*DataFrame|DataFrame,.*Series).*\]
187
+ language : pygrep
188
+ types : [python]
189
+ exclude : ^pandas/_typing\.py$
190
+ - id : inconsistent-namespace-usage
191
+ name : ' Check for inconsistent use of pandas namespace'
192
+ entry : python scripts/check_for_inconsistent_pandas_namespace.py
193
+ language : python
194
+ types : [python]
195
+ - id : no-os-remove
196
+ name : Check code for instances of os.remove
197
+ entry : os\.remove
198
+ language : pygrep
199
+ types : [python]
200
+ files : ^pandas/tests/
201
+ exclude : |
202
+ (?x)^
203
+ pandas/tests/io/excel/test_writers\.py
204
+ |pandas/tests/io/pytables/common\.py
205
+ |pandas/tests/io/pytables/test_store\.py$
187
206
- id : unwanted-patterns
188
207
name : Unwanted patterns
189
208
language : pygrep
@@ -193,6 +212,24 @@ repos:
193
212
\#\ type:\ (?!ignore)
194
213
|\#\ type:\s?ignore(?!\[)
195
214
215
+ # foo._class__ instead of type(foo)
216
+ |\.__class__
217
+
218
+ # np.bool/np.object instead of np.bool_/np.object_
219
+ |np\.bool[^_8]
220
+ |np\.object[^_8]
221
+
222
+ # imports from pandas.core.common instead of `import pandas.core.common as com`
223
+ |from\ pandas\.core\.common\ import
224
+ |from\ pandas\.core\ import\ common
225
+
226
+ # imports from collections.abc instead of `from collections import abc`
227
+ |from\ collections\.abc\ import
228
+
229
+ # Numpy
230
+ |from\ numpy\ import\ random
231
+ |from\ numpy\.random\ import
232
+
196
233
# Incorrect code-block / IPython directives
197
234
|\.\.\ code-block\ ::
198
235
|\.\.\ ipython\ ::
@@ -202,6 +239,7 @@ repos:
202
239
# Check for deprecated messages without sphinx directive
203
240
|(DEPRECATED|DEPRECATE|Deprecated)(:|,|\.)
204
241
types_or : [python, cython, rst]
242
+ exclude : ^doc/source/development/code_style\.rst # contains examples of patterns to avoid
205
243
- id : cython-casting
206
244
name : Check Cython casting is `<type>obj`, not `<type> obj`
207
245
language : pygrep
@@ -232,6 +270,29 @@ repos:
232
270
files : ^pandas/tests/extension/base
233
271
types : [python]
234
272
exclude : ^pandas/tests/extension/base/base\.py
273
+ - id : unwanted-patterns-in-tests
274
+ name : Unwanted patterns in tests
275
+ language : pygrep
276
+ entry : |
277
+ (?x)
278
+ # pytest.xfail instead of pytest.mark.xfail
279
+ pytest\.xfail
280
+
281
+ # imports from pandas._testing instead of `import pandas._testing as tm`
282
+ |from\ pandas\._testing\ import
283
+ |from\ pandas\ import\ _testing\ as\ tm
284
+
285
+ # No direct imports from conftest
286
+ |conftest\ import
287
+ |import\ conftest
288
+
289
+ # pandas.testing instead of tm
290
+ |pd\.testing\.
291
+
292
+ # pd.api.types instead of from pandas.api.types import ...
293
+ |(pd|pandas)\.api\.types\.
294
+ files : ^pandas/tests/
295
+ types_or : [python, cython, rst]
235
296
- id : pip-to-conda
236
297
name : Generate pip dependency from conda
237
298
language : python
@@ -252,6 +313,35 @@ repos:
252
313
language : python
253
314
types : [rst]
254
315
files : ^doc/source/(development|reference)/
316
+ - id : unwanted-patterns-bare-pytest-raises
317
+ name : Check for use of bare pytest raises
318
+ language : python
319
+ entry : python scripts/validate_unwanted_patterns.py --validation-type="bare_pytest_raises"
320
+ types : [python]
321
+ files : ^pandas/tests/
322
+ exclude : ^pandas/tests/extension/
323
+ - id : unwanted-patterns-private-function-across-module
324
+ name : Check for use of private functions across modules
325
+ language : python
326
+ entry : python scripts/validate_unwanted_patterns.py --validation-type="private_function_across_module"
327
+ types : [python]
328
+ exclude : ^(asv_bench|pandas/tests|doc)/
329
+ - id : unwanted-patterns-private-import-across-module
330
+ name : Check for import of private attributes across modules
331
+ language : python
332
+ entry : python scripts/validate_unwanted_patterns.py --validation-type="private_import_across_module"
333
+ types : [python]
334
+ exclude : ^(asv_bench|pandas/tests|doc)/
335
+ - id : unwanted-patterns-strings-to-concatenate
336
+ name : Check for use of not concatenated strings
337
+ language : python
338
+ entry : python scripts/validate_unwanted_patterns.py --validation-type="strings_to_concatenate"
339
+ types_or : [python, cython]
340
+ - id : unwanted-patterns-strings-with-wrong-placed-whitespace
341
+ name : Check for strings with wrong placed spaces
342
+ language : python
343
+ entry : python scripts/validate_unwanted_patterns.py --validation-type="strings_with_wrong_placed_whitespace"
344
+ types_or : [python, cython]
255
345
- id : use-pd_array-in-core
256
346
name : Import pandas.array as pd_array in core
257
347
language : python
0 commit comments