Skip to content

CI move non-standard-import checks over to pre-commit #37240

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 7 commits into from
Oct 22, 2020
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 24 additions & 5 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -56,12 +56,31 @@ repos:
- id: incorrect-sphinx-directives
name: Check for incorrect Sphinx directives
language: pygrep
entry: >-
\.\. (autosummary|contents|currentmodule|deprecated
|function|image|important|include|ipython|literalinclude
|math|module|note|raw|seealso|toctree|versionadded
|versionchanged|warning):[^:]
entry: "\
\\.\\. (autosummary|contents|currentmodule|deprecated\
|function|image|important|include|ipython|literalinclude\
|math|module|note|raw|seealso|toctree|versionadded\
|versionchanged|warning):[^:]"
files: \.(py|pyx|rst)$
- id: non-standard-imports
name: Check for non-standard imports
language: pygrep
entry: "\
from pandas\\.core\\.common import\
|from pandas\\.core import common\
|from collections\\.abc import\
|from numpy import nan"
types: [python]
- id: non-standard-imports-in-tests
name: Check for non-standard imports in test suite
language: pygrep
entry: "\
from pandas\\._testing import\
|from pandas import _testing as tm\
|conftest import\
|import conftest"
types: [python]
files: ^pandas/tests/
- id: incorrect-code-directives
name: Check for incorrect code block or IPython directives
language: pygrep
Expand Down
25 changes: 0 additions & 25 deletions ci/code_checks.sh
Original file line number Diff line number Diff line change
Expand Up @@ -143,31 +143,6 @@ fi
### PATTERNS ###
if [[ -z "$CHECK" || "$CHECK" == "patterns" ]]; then

# Check for imports from pandas.core.common instead of `import pandas.core.common as com`
# Check for imports from collections.abc instead of `from collections import abc`
MSG='Check for non-standard imports' ; echo $MSG
invgrep -R --include="*.py*" -E "from pandas.core.common import" pandas
RET=$(($RET + $?)) ; echo $MSG "DONE"
invgrep -R --include="*.py*" -E "from pandas.core import common" pandas
RET=$(($RET + $?)) ; echo $MSG "DONE"
invgrep -R --include="*.py*" -E "from collections.abc import" pandas
RET=$(($RET + $?)) ; echo $MSG "DONE"
invgrep -R --include="*.py*" -E "from numpy import nan" pandas
RET=$(($RET + $?)) ; echo $MSG "DONE"

# Checks for test suite
# Check for imports from pandas._testing instead of `import pandas._testing as tm`
invgrep -R --include="*.py*" -E "from pandas._testing import" pandas/tests
RET=$(($RET + $?)) ; echo $MSG "DONE"
invgrep -R --include="*.py*" -E "from pandas import _testing as tm" pandas/tests
RET=$(($RET + $?)) ; echo $MSG "DONE"

# No direct imports from conftest
invgrep -R --include="*.py*" -E "conftest import" pandas/tests
RET=$(($RET + $?)) ; echo $MSG "DONE"
invgrep -R --include="*.py*" -E "import conftest" pandas/tests
RET=$(($RET + $?)) ; echo $MSG "DONE"

MSG='Check for use of exec' ; echo $MSG
invgrep -R --include="*.py*" -E "[^a-zA-Z0-9_]exec\(" pandas
RET=$(($RET + $?)) ; echo $MSG "DONE"
Expand Down