Skip to content

Commit 1f14660

Browse files
debnathshohamfeefladder
authored andcommitted
STYLE: moving unwanted pattern check to precommit (pandas-dev#42923)
* STYLE: moving unwanted pattern check to precommit * backtick check on new hook * removed tick check from unwanted * np.random.seed check in asv * added to precommit; removed from code_check.sh * removed patterns entirely from code_check.sh * removed from ci.yml
1 parent 4fcfbc6 commit 1f14660

File tree

3 files changed

+24
-29
lines changed

3 files changed

+24
-29
lines changed

.github/workflows/ci.yml

-4
Original file line numberDiff line numberDiff line change
@@ -32,10 +32,6 @@ jobs:
3232
with:
3333
fetch-depth: 0
3434

35-
- name: Looking for unwanted patterns
36-
run: ci/code_checks.sh patterns
37-
if: always()
38-
3935
- name: Cache conda
4036
uses: actions/cache@v2
4137
with:

.pre-commit-config.yaml

+22
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,29 @@ repos:
102102
# Incorrect code-block / IPython directives
103103
|\.\.\ code-block\ ::
104104
|\.\.\ ipython\ ::
105+
106+
# Check for deprecated messages without sphinx directive
107+
|(DEPRECATED|DEPRECATE|Deprecated)(:|,|\.)
105108
types_or: [python, cython, rst]
109+
- id: incorrect-backticks
110+
name: Check for backticks incorrectly rendering because of missing spaces
111+
language: pygrep
112+
entry: '[a-zA-Z0-9]\`\`?[a-zA-Z0-9]'
113+
types: [rst]
114+
files: ^doc/source/
115+
- id: seed-check-asv
116+
name: Check for unnecessary random seeds in asv benchmarks
117+
language: pygrep
118+
entry: 'np\.random\.seed'
119+
files: ^asv_bench/benchmarks
120+
exclude: ^asv_bench/benchmarks/pandas_vb_common\.py
121+
- id: invalid-ea-testing
122+
name: Check for invalid EA testing
123+
language: pygrep
124+
entry: 'tm\.assert_(series|frame)_equal'
125+
files: ^pandas/tests/extension/base
126+
types: [python]
127+
exclude: ^pandas/tests/extension/base/base\.py
106128
- id: pip-to-conda
107129
name: Generate pip dependency from conda
108130
description: This hook checks if the conda environment.yml and requirements-dev.txt are equal

ci/code_checks.sh

+2-25
Original file line numberDiff line numberDiff line change
@@ -11,14 +11,13 @@
1111
# Usage:
1212
# $ ./ci/code_checks.sh # run all checks
1313
# $ ./ci/code_checks.sh lint # run linting only
14-
# $ ./ci/code_checks.sh patterns # check for patterns that should not exist
1514
# $ ./ci/code_checks.sh code # checks on imported code
1615
# $ ./ci/code_checks.sh doctests # run doctests
1716
# $ ./ci/code_checks.sh docstrings # validate docstring errors
1817
# $ ./ci/code_checks.sh typing # run static type analysis
1918

20-
[[ -z "$1" || "$1" == "lint" || "$1" == "patterns" || "$1" == "code" || "$1" == "doctests" || "$1" == "docstrings" || "$1" == "typing" ]] || \
21-
{ echo "Unknown command $1. Usage: $0 [lint|patterns|code|doctests|docstrings|typing]"; exit 9999; }
19+
[[ -z "$1" || "$1" == "lint" || "$1" == "code" || "$1" == "doctests" || "$1" == "docstrings" || "$1" == "typing" ]] || \
20+
{ echo "Unknown command $1. Usage: $0 [lint|code|doctests|docstrings|typing]"; exit 9999; }
2221

2322
BASE_DIR="$(dirname $0)/.."
2423
RET=0
@@ -58,28 +57,6 @@ if [[ -z "$CHECK" || "$CHECK" == "lint" ]]; then
5857

5958
fi
6059

61-
### PATTERNS ###
62-
if [[ -z "$CHECK" || "$CHECK" == "patterns" ]]; then
63-
64-
# Check for the following code in the extension array base tests: `tm.assert_frame_equal` and `tm.assert_series_equal`
65-
MSG='Check for invalid EA testing' ; echo $MSG
66-
invgrep -r -E --include '*.py' --exclude base.py 'tm.assert_(series|frame)_equal' pandas/tests/extension/base
67-
RET=$(($RET + $?)) ; echo $MSG "DONE"
68-
69-
MSG='Check for deprecated messages without sphinx directive' ; echo $MSG
70-
invgrep -R --include="*.py" --include="*.pyx" -E "(DEPRECATED|DEPRECATE|Deprecated)(:|,|\.)" pandas
71-
RET=$(($RET + $?)) ; echo $MSG "DONE"
72-
73-
MSG='Check for backticks incorrectly rendering because of missing spaces' ; echo $MSG
74-
invgrep -R --include="*.rst" -E "[a-zA-Z0-9]\`\`?[a-zA-Z0-9]" doc/source/
75-
RET=$(($RET + $?)) ; echo $MSG "DONE"
76-
77-
MSG='Check for unnecessary random seeds in asv benchmarks' ; echo $MSG
78-
invgrep -R --exclude pandas_vb_common.py -E 'np.random.seed' asv_bench/benchmarks/
79-
RET=$(($RET + $?)) ; echo $MSG "DONE"
80-
81-
fi
82-
8360
### CODE ###
8461
if [[ -z "$CHECK" || "$CHECK" == "code" ]]; then
8562

0 commit comments

Comments
 (0)