Skip to content

Commit c801ff4

Browse files
MarcoGorelliMarco Gorelli
authored and
Marco Gorelli
committed
move non-standard-imports over to pre-commit
1 parent de5349a commit c801ff4

File tree

2 files changed

+25
-30
lines changed

2 files changed

+25
-30
lines changed

.pre-commit-config.yaml

+25-5
Original file line numberDiff line numberDiff line change
@@ -56,12 +56,32 @@ repos:
5656
- id: incorrect-sphinx-directives
5757
name: Check for incorrect Sphinx directives
5858
language: pygrep
59-
entry: >-
60-
\.\. (autosummary|contents|currentmodule|deprecated
61-
|function|image|important|include|ipython|literalinclude
62-
|math|module|note|raw|seealso|toctree|versionadded
63-
|versionchanged|warning):[^:]
59+
entry: "\
60+
\\.\\. (autosummary|contents|currentmodule|deprecated\
61+
|function|image|important|include|ipython\
62+
|literalinclude|math|module|note|raw|seealso\
63+
|toctree|versionadded|versionchanged|warning\
64+
):[^:]"
6465
files: \.(py|pyx|rst)$
66+
- id: non-standard-imports
67+
name: Check for non-standard imports
68+
language: pygrep
69+
entry: "\
70+
from pandas\\.core.common import\
71+
|from pandas\\.core import common\
72+
|from collections\\.abc import\
73+
|from numpy import nan"
74+
types: [python]
75+
- id: non-standard-imports-in-tests
76+
name: Check for non-standard imports in test suite
77+
language: pygrep
78+
entry: "\
79+
from pandas\\._testing import\
80+
|from pandas import _testing as tm\
81+
|conftest import\
82+
|import conftest"
83+
types: [python]
84+
files: ^pandas/tests/
6585
- id: incorrect-code-directives
6686
name: Check for incorrect code block or IPython directives
6787
language: pygrep

ci/code_checks.sh

-25
Original file line numberDiff line numberDiff line change
@@ -143,31 +143,6 @@ fi
143143
### PATTERNS ###
144144
if [[ -z "$CHECK" || "$CHECK" == "patterns" ]]; then
145145

146-
# Check for imports from pandas.core.common instead of `import pandas.core.common as com`
147-
# Check for imports from collections.abc instead of `from collections import abc`
148-
MSG='Check for non-standard imports' ; echo $MSG
149-
invgrep -R --include="*.py*" -E "from pandas.core.common import" pandas
150-
RET=$(($RET + $?)) ; echo $MSG "DONE"
151-
invgrep -R --include="*.py*" -E "from pandas.core import common" pandas
152-
RET=$(($RET + $?)) ; echo $MSG "DONE"
153-
invgrep -R --include="*.py*" -E "from collections.abc import" pandas
154-
RET=$(($RET + $?)) ; echo $MSG "DONE"
155-
invgrep -R --include="*.py*" -E "from numpy import nan" pandas
156-
RET=$(($RET + $?)) ; echo $MSG "DONE"
157-
158-
# Checks for test suite
159-
# Check for imports from pandas._testing instead of `import pandas._testing as tm`
160-
invgrep -R --include="*.py*" -E "from pandas._testing import" pandas/tests
161-
RET=$(($RET + $?)) ; echo $MSG "DONE"
162-
invgrep -R --include="*.py*" -E "from pandas import _testing as tm" pandas/tests
163-
RET=$(($RET + $?)) ; echo $MSG "DONE"
164-
165-
# No direct imports from conftest
166-
invgrep -R --include="*.py*" -E "conftest import" pandas/tests
167-
RET=$(($RET + $?)) ; echo $MSG "DONE"
168-
invgrep -R --include="*.py*" -E "import conftest" pandas/tests
169-
RET=$(($RET + $?)) ; echo $MSG "DONE"
170-
171146
MSG='Check for use of exec' ; echo $MSG
172147
invgrep -R --include="*.py*" -E "[^a-zA-Z0-9_]exec\(" pandas
173148
RET=$(($RET + $?)) ; echo $MSG "DONE"

0 commit comments

Comments
 (0)