@@ -90,11 +90,6 @@ repos:
9090 entry : python scripts/check_for_inconsistent_pandas_namespace.py
9191 language : python
9292 types : [python]
93- - id : incorrect-code-directives
94- name : Check for incorrect code block or IPython directives
95- language : pygrep
96- entry : (\.\. code-block ::|\.\. ipython ::)
97- types_or : [python, cython, rst]
9893 - id : no-os-remove
9994 name : Check code for instances of os.remove
10095 entry : os\.remove
@@ -106,49 +101,60 @@ repos:
106101 pandas/tests/io/excel/test_writers\.py
107102 |pandas/tests/io/pytables/common\.py
108103 |pandas/tests/io/pytables/test_store\.py$
109- - id : non-standard-imports
110- name : Check for non-standard imports
104+ - id : unwanted-patterns
105+ name : Unwanted patterns
111106 language : pygrep
112107 entry : |
113108 (?x)
114- # Check for imports from pandas.core.common instead of `import pandas.core.common as com`
115- from\ pandas\.core\.common\ import
109+ # outdated annotation syntax, missing error codes
110+ \#\ type:\ (?!ignore)
111+ |\#\ type:\s?ignore(?!\[)
112+
113+ # foo._class__ instead of type(foo)
114+ |\.__class__
115+
116+ # np.bool/np.object instead of np.bool_/np.object_
117+ |np\.bool[^_8]
118+ |np\.object[^_8]
119+
120+ # imports from pandas.core.common instead of `import pandas.core.common as com`
121+ |from\ pandas\.core\.common\ import
116122 |from\ pandas\.core\ import\ common
117123
118- # Check for imports from collections.abc instead of `from collections import abc`
124+ # imports from collections.abc instead of `from collections import abc`
119125 |from\ collections\.abc\ import
120126
121127 # Numpy
122128 |from\ numpy\ import\ random
123129 |from\ numpy\.random\ import
124- types : [python]
125- - id : non-standard-imports-in-tests
126- name : Check for non-standard imports in test suite
130+
131+ # Incorrect code-block / IPython directives
132+ |\.\.\ code-block\ ::
133+ |\.\.\ ipython\ ::
134+ types_or : [python, cython, rst]
135+ exclude : ^doc/source/development/code_style\.rst # contains examples of patterns to avoid
136+ - id : unwanted-patterns-in-tests
137+ name : Unwanted patterns in tests
127138 language : pygrep
128139 entry : |
129140 (?x)
130- # Check for imports from pandas._testing instead of `import pandas._testing as tm`
131- from\ pandas\._testing\ import
141+ # pytest.xfail instead of pytest.mark.xfail
142+ pytest\.xfail
143+
144+ # imports from pandas._testing instead of `import pandas._testing as tm`
145+ |from\ pandas\._testing\ import
132146 |from\ pandas\ import\ _testing\ as\ tm
133147
134148 # No direct imports from conftest
135149 |conftest\ import
136150 |import\ conftest
137151
138- # Check for use of pandas.testing instead of tm
152+ # pandas.testing instead of tm
139153 |pd\.testing\.
140154
141- # Check for pd.api.types instead of from pandas.api.types import ...
155+ # pd.api.types instead of from pandas.api.types import ...
142156 |(pd|pandas)\.api\.types\.
143- types : [python]
144157 files : ^pandas/tests/
145- - id : np-bool-and-np-object
146- name : Check for use of np.bool/np.object instead of np.bool_/np.object_
147- entry : |
148- (?x)
149- np\.bool[^_8]
150- |np\.object[^_8]
151- language : pygrep
152158 types_or : [python, cython, rst]
153159 - id : pip-to-conda
154160 name : Generate pip dependency from conda
@@ -164,11 +170,6 @@ repos:
164170 language : python
165171 types : [rst]
166172 files : ^doc/source/(development|reference)/
167- - id : type-not-class
168- name : Check for use of foo.__class__ instead of type(foo)
169- entry : \.__class__
170- language : pygrep
171- types_or : [python, cython]
172173 - id : unwanted-patterns-bare-pytest-raises
173174 name : Check for use of bare pytest raises
174175 language : python
@@ -188,12 +189,6 @@ repos:
188189 entry : python scripts/validate_unwanted_patterns.py --validation-type="private_import_across_module"
189190 types : [python]
190191 exclude : ^(asv_bench|pandas/tests|doc)/
191- - id : unwanted-patterns-pytest-xfail
192- name : Check for use of pytest.xfail
193- entry : pytest\.xfail
194- language : pygrep
195- types : [python]
196- files : ^pandas/tests/
197192 - id : unwanted-patterns-strings-to-concatenate
198193 name : Check for use of not concatenated strings
199194 language : python
@@ -204,14 +199,6 @@ repos:
204199 language : python
205200 entry : python scripts/validate_unwanted_patterns.py --validation-type="strings_with_wrong_placed_whitespace"
206201 types_or : [python, cython]
207- - id : unwanted-typing
208- name : Check for outdated annotation syntax and missing error codes
209- entry : |
210- (?x)
211- \#\ type:\ (?!ignore)
212- |\#\ type:\s?ignore(?!\[)
213- language : pygrep
214- types : [python]
215202 - id : use-pd_array-in-core
216203 name : Import pandas.array as pd_array in core
217204 language : python
0 commit comments