@@ -70,12 +70,9 @@ repos:
7070 rev : 6.0.0
7171 hooks :
7272 - id : flake8
73- # Need to patch os.remove rule in pandas-dev-flaker
74- exclude : ^ci/fix_wheels.py
7573 additional_dependencies : &flake8_dependencies
7674 - flake8==6.0.0
7775 - flake8-bugbear==22.7.1
78- - pandas-dev-flaker==0.5.0
7976- repo : https://github.com/pycqa/pylint
8077 rev : v2.15.9
8178 hooks :
@@ -183,6 +180,21 @@ repos:
183180 types : [rst]
184181 args : [--filename=*.rst]
185182 additional_dependencies : [flake8-rst==0.7.0, flake8==3.7.9]
183+ - id : inconsistent-namespace-usage
184+ name : ' Check for inconsistent use of pandas namespace'
185+ entry : python scripts/check_for_inconsistent_pandas_namespace.py
186+ exclude : ^pandas/core/interchange/
187+ language : python
188+ types : [python]
189+ - id : no-os-remove
190+ name : Check code for instances of os.remove
191+ entry : os\.remove
192+ language : pygrep
193+ types : [python]
194+ files : ^pandas/tests/
195+ exclude : |
196+ (?x)^
197+ pandas/tests/io/pytables/test_store\.py$
186198 - id : unwanted-patterns
187199 name : Unwanted patterns
188200 language : pygrep
@@ -192,6 +204,20 @@ repos:
192204 \#\ type:\ (?!ignore)
193205 |\#\ type:\s?ignore(?!\[)
194206
207+ # foo._class__ instead of type(foo)
208+ |\.__class__
209+
210+ # np.bool/np.object instead of np.bool_/np.object_
211+ |np\.bool[^_8`]
212+ |np\.object[^_8`]
213+
214+ # imports from collections.abc instead of `from collections import abc`
215+ |from\ collections\.abc\ import
216+
217+ # Numpy
218+ |from\ numpy\ import\ random
219+ |from\ numpy\.random\ import
220+
195221 # Incorrect code-block / IPython directives
196222 |\.\.\ code-block\ ::
197223 |\.\.\ ipython\ ::
@@ -200,7 +226,17 @@ repos:
200226
201227 # Check for deprecated messages without sphinx directive
202228 |(DEPRECATED|DEPRECATE|Deprecated)(:|,|\.)
229+
230+ # {foo!r} instead of {repr(foo)}
231+ |!r}
232+
233+ # builtin filter function
234+ |(?<!def)[\(\s]filter\(
235+
236+ # exec
237+ |[^a-zA-Z0-9_]exec\(
203238 types_or : [python, cython, rst]
239+ exclude : ^doc/source/development/code_style\.rst # contains examples of patterns to avoid
204240 - id : cython-casting
205241 name : Check Cython casting is `<type>obj`, not `<type> obj`
206242 language : pygrep
@@ -231,6 +267,58 @@ repos:
231267 files : ^pandas/tests/extension/base
232268 types : [python]
233269 exclude : ^pandas/tests/extension/base/base\.py
270+ - id : unwanted-patterns-in-tests
271+ name : Unwanted patterns in tests
272+ language : pygrep
273+ entry : |
274+ (?x)
275+ # pytest.xfail instead of pytest.mark.xfail
276+ pytest\.xfail
277+
278+ # imports from pandas._testing instead of `import pandas._testing as tm`
279+ |from\ pandas\._testing\ import
280+ |from\ pandas\ import\ _testing\ as\ tm
281+
282+ # No direct imports from conftest
283+ |conftest\ import
284+ |import\ conftest
285+
286+ # pandas.testing instead of tm
287+ |pd\.testing\.
288+
289+ # pd.api.types instead of from pandas.api.types import ...
290+ |(pd|pandas)\.api\.types\.
291+
292+ # np.testing, np.array_equal
293+ |(numpy|np)(\.testing|\.array_equal)
294+
295+ # unittest.mock (use pytest builtin monkeypatch fixture instead)
296+ |(unittest(\.| import )mock|mock\.Mock\(\)|mock\.patch)
297+
298+ # pytest raises without context
299+ |\s\ pytest.raises
300+
301+ # pytest.warns (use tm.assert_produces_warning instead)
302+ |pytest\.warns
303+ files : ^pandas/tests/
304+ types_or : [python, cython, rst]
305+ - id : unwanted-patterns-in-ea-tests
306+ name : Unwanted patterns in EA tests
307+ language : pygrep
308+ entry : |
309+ (?x)
310+ tm.assert_(series|frame)_equal
311+ files : ^pandas/tests/extension/base/
312+ exclude : ^pandas/tests/extension/base/base\.py$
313+ types_or : [python, cython, rst]
314+ - id : unwanted-patterns-in-cython
315+ name : Unwanted patterns in Cython code
316+ language : pygrep
317+ entry : |
318+ (?x)
319+ # `<type>obj` as opposed to `<type> obj`
320+ [a-zA-Z0-9*]>[ ]
321+ types : [cython]
234322 - id : pip-to-conda
235323 name : Generate pip dependency from conda
236324 language : python
@@ -251,6 +339,38 @@ repos:
251339 language : python
252340 types : [rst]
253341 files : ^doc/source/(development|reference)/
342+ - id : unwanted-patterns-bare-pytest-raises
343+ name : Check for use of bare pytest raises
344+ language : python
345+ entry : python scripts/validate_unwanted_patterns.py --validation-type="bare_pytest_raises"
346+ types : [python]
347+ files : ^pandas/tests/
348+ exclude : ^pandas/tests/extension/
349+ - id : unwanted-patterns-private-function-across-module
350+ name : Check for use of private functions across modules
351+ language : python
352+ entry : python scripts/validate_unwanted_patterns.py --validation-type="private_function_across_module"
353+ types : [python]
354+ exclude : ^(asv_bench|pandas/tests|doc)/
355+ - id : unwanted-patterns-private-import-across-module
356+ name : Check for import of private attributes across modules
357+ language : python
358+ entry : python scripts/validate_unwanted_patterns.py --validation-type="private_import_across_module"
359+ types : [python]
360+ exclude : |
361+ (?x)
362+ ^(asv_bench|pandas/tests|doc)/
363+ |scripts/validate_min_versions_in_sync\.py$
364+ - id : unwanted-patterns-strings-to-concatenate
365+ name : Check for use of not concatenated strings
366+ language : python
367+ entry : python scripts/validate_unwanted_patterns.py --validation-type="strings_to_concatenate"
368+ types_or : [python, cython]
369+ - id : unwanted-patterns-strings-with-misplaced-whitespace
370+ name : Check for strings with misplaced spaces
371+ language : python
372+ entry : python scripts/validate_unwanted_patterns.py --validation-type="strings_with_wrong_placed_whitespace"
373+ types_or : [python, cython]
254374 - id : use-pd_array-in-core
255375 name : Import pandas.array as pd_array in core
256376 language : python
0 commit comments