Skip to content

Commit 0d1f75d

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

File tree

2 files changed

+24
-30
lines changed

2 files changed

+24
-30
lines changed

.pre-commit-config.yaml

+24-5
Original file line numberDiff line numberDiff line change
@@ -56,12 +56,31 @@ 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|literalinclude\
62+
|math|module|note|raw|seealso|toctree|versionadded\
63+
|versionchanged|warning):[^:]"
6464
files: \.(py|pyx|rst)$
65+
- id: non-standard-imports
66+
name: Check for non-standard imports
67+
language: pygrep
68+
entry: "\
69+
from pandas\\.core.common import\
70+
|from pandas\\.core import common\
71+
|from collections\\.abc import\
72+
|from numpy import nan"
73+
types: [python]
74+
- id: non-standard-imports-in-tests
75+
name: Check for non-standard imports in test suite
76+
language: pygrep
77+
entry: "\
78+
from pandas\\._testing import\
79+
|from pandas import _testing as tm\
80+
|conftest import\
81+
|import conftest"
82+
types: [python]
83+
files: ^pandas/tests/
6584
- id: incorrect-code-directives
6685
name: Check for incorrect code block or IPython directives
6786
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)