diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index bf76033f769b5..b9fe5461aff37 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -32,10 +32,6 @@ jobs: with: fetch-depth: 0 - - name: Looking for unwanted patterns - run: ci/code_checks.sh patterns - if: always() - - name: Cache conda uses: actions/cache@v2 with: diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index dca1a84867e72..a83de7309c116 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -102,7 +102,29 @@ repos: # Incorrect code-block / IPython directives |\.\.\ code-block\ :: |\.\.\ ipython\ :: + + # Check for deprecated messages without sphinx directive + |(DEPRECATED|DEPRECATE|Deprecated)(:|,|\.) types_or: [python, cython, rst] + - id: incorrect-backticks + name: Check for backticks incorrectly rendering because of missing spaces + language: pygrep + entry: '[a-zA-Z0-9]\`\`?[a-zA-Z0-9]' + types: [rst] + files: ^doc/source/ + - id: seed-check-asv + name: Check for unnecessary random seeds in asv benchmarks + language: pygrep + entry: 'np\.random\.seed' + files: ^asv_bench/benchmarks + exclude: ^asv_bench/benchmarks/pandas_vb_common\.py + - id: invalid-ea-testing + name: Check for invalid EA testing + language: pygrep + entry: 'tm\.assert_(series|frame)_equal' + files: ^pandas/tests/extension/base + types: [python] + exclude: ^pandas/tests/extension/base/base\.py - id: pip-to-conda name: Generate pip dependency from conda description: This hook checks if the conda environment.yml and requirements-dev.txt are equal diff --git a/ci/code_checks.sh b/ci/code_checks.sh index 46c03458e32c4..0d05d50bd7dd6 100755 --- a/ci/code_checks.sh +++ b/ci/code_checks.sh @@ -11,14 +11,13 @@ # Usage: # $ ./ci/code_checks.sh # run all checks # $ ./ci/code_checks.sh lint # run linting only -# $ ./ci/code_checks.sh patterns # check for patterns that should not exist # $ ./ci/code_checks.sh code # checks on imported code # $ ./ci/code_checks.sh doctests # run doctests # $ ./ci/code_checks.sh docstrings # validate docstring errors # $ ./ci/code_checks.sh typing # run static type analysis -[[ -z "$1" || "$1" == "lint" || "$1" == "patterns" || "$1" == "code" || "$1" == "doctests" || "$1" == "docstrings" || "$1" == "typing" ]] || \ - { echo "Unknown command $1. Usage: $0 [lint|patterns|code|doctests|docstrings|typing]"; exit 9999; } +[[ -z "$1" || "$1" == "lint" || "$1" == "code" || "$1" == "doctests" || "$1" == "docstrings" || "$1" == "typing" ]] || \ + { echo "Unknown command $1. Usage: $0 [lint|code|doctests|docstrings|typing]"; exit 9999; } BASE_DIR="$(dirname $0)/.." RET=0 @@ -58,28 +57,6 @@ if [[ -z "$CHECK" || "$CHECK" == "lint" ]]; then fi -### PATTERNS ### -if [[ -z "$CHECK" || "$CHECK" == "patterns" ]]; then - - # Check for the following code in the extension array base tests: `tm.assert_frame_equal` and `tm.assert_series_equal` - MSG='Check for invalid EA testing' ; echo $MSG - invgrep -r -E --include '*.py' --exclude base.py 'tm.assert_(series|frame)_equal' pandas/tests/extension/base - RET=$(($RET + $?)) ; echo $MSG "DONE" - - MSG='Check for deprecated messages without sphinx directive' ; echo $MSG - invgrep -R --include="*.py" --include="*.pyx" -E "(DEPRECATED|DEPRECATE|Deprecated)(:|,|\.)" pandas - RET=$(($RET + $?)) ; echo $MSG "DONE" - - MSG='Check for backticks incorrectly rendering because of missing spaces' ; echo $MSG - invgrep -R --include="*.rst" -E "[a-zA-Z0-9]\`\`?[a-zA-Z0-9]" doc/source/ - RET=$(($RET + $?)) ; echo $MSG "DONE" - - MSG='Check for unnecessary random seeds in asv benchmarks' ; echo $MSG - invgrep -R --exclude pandas_vb_common.py -E 'np.random.seed' asv_bench/benchmarks/ - RET=$(($RET + $?)) ; echo $MSG "DONE" - -fi - ### CODE ### if [[ -z "$CHECK" || "$CHECK" == "code" ]]; then