Skip to content

Commit 14b4793

Browse files
MarcoGorelliJulianWgs
authored andcommitted
CI move non-standard-import checks over to pre-commit (pandas-dev#37240)
1 parent daff98c commit 14b4793

File tree

2 files changed

+37
-30
lines changed

2 files changed

+37
-30
lines changed

.pre-commit-config.yaml

+37-5
Original file line numberDiff line numberDiff line change
@@ -56,12 +56,44 @@ 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+
(?x)
61+
# Check for cases of e.g. .. warning: instead of .. warning::
62+
\.\.\ (
63+
autosummary|contents|currentmodule|deprecated|
64+
function|image|important|include|ipython|literalinclude|
65+
math|module|note|raw|seealso|toctree|versionadded|
66+
versionchanged|warning
67+
):[^:]
6468
files: \.(py|pyx|rst)$
69+
- id: non-standard-imports
70+
name: Check for non-standard imports
71+
language: pygrep
72+
entry: |
73+
(?x)
74+
# Check for imports from pandas.core.common instead of `import pandas.core.common as com`
75+
from\ pandas\.core\.common\ import|
76+
from\ pandas\.core\ import\ common|
77+
78+
# Check for imports from collections.abc instead of `from collections import abc`
79+
from\ collections\.abc\ import|
80+
81+
from\ numpy\ import\ nan
82+
types: [python]
83+
- id: non-standard-imports-in-tests
84+
name: Check for non-standard imports in test suite
85+
language: pygrep
86+
entry: |
87+
(?x)
88+
# Check for imports from pandas._testing instead of `import pandas._testing as tm`
89+
from\ pandas\._testing\ import|
90+
from\ pandas\ import\ _testing\ as\ tm|
91+
92+
# No direct imports from conftest
93+
conftest\ import|
94+
import\ conftest
95+
types: [python]
96+
files: ^pandas/tests/
6597
- id: incorrect-code-directives
6698
name: Check for incorrect code block or IPython directives
6799
language: pygrep

ci/code_checks.sh

-25
Original file line numberDiff line numberDiff line change
@@ -110,31 +110,6 @@ fi
110110
### PATTERNS ###
111111
if [[ -z "$CHECK" || "$CHECK" == "patterns" ]]; then
112112

113-
# Check for imports from pandas.core.common instead of `import pandas.core.common as com`
114-
# Check for imports from collections.abc instead of `from collections import abc`
115-
MSG='Check for non-standard imports' ; echo $MSG
116-
invgrep -R --include="*.py*" -E "from pandas.core.common import" pandas
117-
RET=$(($RET + $?)) ; echo $MSG "DONE"
118-
invgrep -R --include="*.py*" -E "from pandas.core import common" pandas
119-
RET=$(($RET + $?)) ; echo $MSG "DONE"
120-
invgrep -R --include="*.py*" -E "from collections.abc import" pandas
121-
RET=$(($RET + $?)) ; echo $MSG "DONE"
122-
invgrep -R --include="*.py*" -E "from numpy import nan" pandas
123-
RET=$(($RET + $?)) ; echo $MSG "DONE"
124-
125-
# Checks for test suite
126-
# Check for imports from pandas._testing instead of `import pandas._testing as tm`
127-
invgrep -R --include="*.py*" -E "from pandas._testing import" pandas/tests
128-
RET=$(($RET + $?)) ; echo $MSG "DONE"
129-
invgrep -R --include="*.py*" -E "from pandas import _testing as tm" pandas/tests
130-
RET=$(($RET + $?)) ; echo $MSG "DONE"
131-
132-
# No direct imports from conftest
133-
invgrep -R --include="*.py*" -E "conftest import" pandas/tests
134-
RET=$(($RET + $?)) ; echo $MSG "DONE"
135-
invgrep -R --include="*.py*" -E "import conftest" pandas/tests
136-
RET=$(($RET + $?)) ; echo $MSG "DONE"
137-
138113
MSG='Check for use of exec' ; echo $MSG
139114
invgrep -R --include="*.py*" -E "[^a-zA-Z0-9_]exec\(" pandas
140115
RET=$(($RET + $?)) ; echo $MSG "DONE"

0 commit comments

Comments
 (0)