From 922d582b8927c3315bfa6603a2c74e82ee11e903 Mon Sep 17 00:00:00 2001 From: debnathshoham Date: Sat, 7 Aug 2021 17:07:26 +0530 Subject: [PATCH 1/7] STYLE: moving unwanted pattern check to precommit --- .pre-commit-config.yaml | 6 ++++++ ci/code_checks.sh | 8 -------- 2 files changed, 6 insertions(+), 8 deletions(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index dca1a84867e72..a7b8afedc5073 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -102,6 +102,12 @@ repos: # Incorrect code-block / IPython directives |\.\.\ code-block\ :: |\.\.\ ipython\ :: + + # Check for deprecated messages without sphinx directive + |(DEPRECATED|DEPRECATE|Deprecated)(:|,|\.) + + # Check for backticks incorrectly rendering because of missing spaces + |[a-zA-Z0-9]\`\`?[a-zA-Z0-9] types_or: [python, cython, rst] - id: pip-to-conda name: Generate pip dependency from conda diff --git a/ci/code_checks.sh b/ci/code_checks.sh index 46c03458e32c4..2afc89c036188 100755 --- a/ci/code_checks.sh +++ b/ci/code_checks.sh @@ -66,14 +66,6 @@ if [[ -z "$CHECK" || "$CHECK" == "patterns" ]]; then 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" From 617e6091328c59eae9272094df9f38d5326b826e Mon Sep 17 00:00:00 2001 From: debnathshoham Date: Sat, 7 Aug 2021 17:43:08 +0530 Subject: [PATCH 2/7] backtick check on new hook --- .pre-commit-config.yaml | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index a7b8afedc5073..0e1f4f8046bc0 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -109,6 +109,13 @@ repos: # Check for backticks incorrectly rendering because of missing spaces |[a-zA-Z0-9]\`\`?[a-zA-Z0-9] types_or: [python, cython, rst] + - id: incorrect-backticks + name: incorrect-backticks + description: 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: pip-to-conda name: Generate pip dependency from conda description: This hook checks if the conda environment.yml and requirements-dev.txt are equal From 6f66c4613e1f4fdda01dfee4cbd5bcac21fbb463 Mon Sep 17 00:00:00 2001 From: debnathshoham Date: Sat, 7 Aug 2021 17:47:24 +0530 Subject: [PATCH 3/7] removed tick check from unwanted --- .pre-commit-config.yaml | 3 --- 1 file changed, 3 deletions(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 0e1f4f8046bc0..4c9af6092ddcf 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -105,9 +105,6 @@ repos: # Check for deprecated messages without sphinx directive |(DEPRECATED|DEPRECATE|Deprecated)(:|,|\.) - - # Check for backticks incorrectly rendering because of missing spaces - |[a-zA-Z0-9]\`\`?[a-zA-Z0-9] types_or: [python, cython, rst] - id: incorrect-backticks name: incorrect-backticks From 9159572cc44f9fb90830df3415515af4d9f94b43 Mon Sep 17 00:00:00 2001 From: debnathshoham Date: Sat, 7 Aug 2021 18:01:37 +0530 Subject: [PATCH 4/7] np.random.seed check in asv --- .pre-commit-config.yaml | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 4c9af6092ddcf..c4b76ebcd3df4 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -113,6 +113,12 @@ repos: 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: pip-to-conda name: Generate pip dependency from conda description: This hook checks if the conda environment.yml and requirements-dev.txt are equal From b2925213bf45a85ff56053b96a7eb12bfcbc5484 Mon Sep 17 00:00:00 2001 From: debnathshoham Date: Sat, 7 Aug 2021 18:08:32 +0530 Subject: [PATCH 5/7] added to precommit; removed from code_check.sh --- .pre-commit-config.yaml | 10 ++++++++-- ci/code_checks.sh | 14 -------------- 2 files changed, 8 insertions(+), 16 deletions(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index c4b76ebcd3df4..bb306db32898b 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -107,8 +107,7 @@ repos: |(DEPRECATED|DEPRECATE|Deprecated)(:|,|\.) types_or: [python, cython, rst] - id: incorrect-backticks - name: incorrect-backticks - description: Check for backticks incorrectly rendering because of missing spaces + name: Check for backticks incorrectly rendering because of missing spaces language: pygrep entry: '[a-zA-Z0-9]\`\`?[a-zA-Z0-9]' types: [rst] @@ -119,6 +118,13 @@ repos: 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 2afc89c036188..36775d6225f2b 100755 --- a/ci/code_checks.sh +++ b/ci/code_checks.sh @@ -58,20 +58,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 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 From e36c8f3a1bacfa3d106d4c0fbfa826c5b813a1b3 Mon Sep 17 00:00:00 2001 From: debnathshoham Date: Sat, 7 Aug 2021 18:15:39 +0530 Subject: [PATCH 6/7] removed patterns entirely from code_check.sh --- ci/code_checks.sh | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/ci/code_checks.sh b/ci/code_checks.sh index 36775d6225f2b..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 From a2b460c85378a5791241515a550e7302cff1df18 Mon Sep 17 00:00:00 2001 From: debnathshoham Date: Sat, 7 Aug 2021 18:40:54 +0530 Subject: [PATCH 7/7] removed from ci.yml --- .github/workflows/ci.yml | 4 ---- .pre-commit-config.yaml | 8 ++++---- 2 files changed, 4 insertions(+), 8 deletions(-) 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 bb306db32898b..a83de7309c116 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -115,16 +115,16 @@ repos: - id: seed-check-asv name: Check for unnecessary random seeds in asv benchmarks language: pygrep - entry: 'np.random.seed' + entry: 'np\.random\.seed' files: ^asv_bench/benchmarks - exclude: ^asv_bench/benchmarks/pandas_vb_common.py + 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' + entry: 'tm\.assert_(series|frame)_equal' files: ^pandas/tests/extension/base types: [python] - exclude: ^pandas/tests/extension/base/base.py + 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