Skip to content

Commit 449c56a

Browse files
STYLE: moving spacing conventions in cython casting to pre-commit (#42186)
* STYLE: moving spacing conventions in cython casting to pre-commit * BUG: Fix pre-commit hook for cython casting check * ENH: Add new hook for cython casting * ENH: Changed hook for cython casting * Update .pre-commit-config.yaml * Update code_checks.sh * ENH: Removed lint comments from code checks * DOC: Changed documentation for code check * mention imports and typing in doc Co-authored-by: Marco Edward Gorelli <[email protected]>
1 parent 77443dc commit 449c56a

File tree

4 files changed

+12
-32
lines changed

4 files changed

+12
-32
lines changed

.github/workflows/ci.yml

-4
Original file line numberDiff line numberDiff line change
@@ -48,10 +48,6 @@ jobs:
4848
- name: Build Pandas
4949
uses: ./.github/actions/build_pandas
5050

51-
- name: Linting
52-
run: ci/code_checks.sh lint
53-
if: always()
54-
5551
- name: Checks on imported code
5652
run: ci/code_checks.sh code
5753
if: always()

.pre-commit-config.yaml

+5
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,11 @@ repos:
107107
# Check for deprecated messages without sphinx directive
108108
|(DEPRECATED|DEPRECATE|Deprecated)(:|,|\.)
109109
types_or: [python, cython, rst]
110+
- id: cython-casting
111+
name: Check Cython casting is `<type>obj`, not `<type> obj`
112+
language: pygrep
113+
entry: '[a-zA-Z0-9*]> '
114+
files: (\.pyx|\.pxi.in)$
110115
- id: incorrect-backticks
111116
name: Check for backticks incorrectly rendering because of missing spaces
112117
language: pygrep

ci/code_checks.sh

+3-23
Original file line numberDiff line numberDiff line change
@@ -3,21 +3,18 @@
33
# Run checks related to code quality.
44
#
55
# This script is intended for both the CI and to check locally that code standards are
6-
# respected. We are currently linting (PEP-8 and similar), looking for patterns of
7-
# common mistakes (sphinx directives with missing blank lines, old style classes,
8-
# unwanted imports...), we run doctests here (currently some files only), and we
6+
# respected. We run doctests here (currently some files only), and we
97
# validate formatting error in docstrings.
108
#
119
# Usage:
1210
# $ ./ci/code_checks.sh # run all checks
13-
# $ ./ci/code_checks.sh lint # run linting only
1411
# $ ./ci/code_checks.sh code # checks on imported code
1512
# $ ./ci/code_checks.sh doctests # run doctests
1613
# $ ./ci/code_checks.sh docstrings # validate docstring errors
1714
# $ ./ci/code_checks.sh typing # run static type analysis
1815

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; }
16+
[[ -z "$1" || "$1" == "code" || "$1" == "doctests" || "$1" == "docstrings" || "$1" == "typing" ]] || \
17+
{ echo "Unknown command $1. Usage: $0 [code|doctests|docstrings|typing]"; exit 9999; }
2118

2219
BASE_DIR="$(dirname $0)/.."
2320
RET=0
@@ -40,23 +37,6 @@ if [[ "$GITHUB_ACTIONS" == "true" ]]; then
4037
INVGREP_PREPEND="##[error]"
4138
fi
4239

43-
### LINTING ###
44-
if [[ -z "$CHECK" || "$CHECK" == "lint" ]]; then
45-
46-
# Check that cython casting is of the form `<type>obj` as opposed to `<type> obj`;
47-
# it doesn't make a difference, but we want to be internally consistent.
48-
# Note: this grep pattern is (intended to be) equivalent to the python
49-
# regex r'(?<![ ->])> '
50-
MSG='Linting .pyx code for spacing conventions in casting' ; echo $MSG
51-
invgrep -r -E --include '*.pyx' --include '*.pxi.in' '[a-zA-Z0-9*]> ' pandas/_libs
52-
RET=$(($RET + $?)) ; echo $MSG "DONE"
53-
54-
# readability/casting: Warnings about C casting instead of C++ casting
55-
# runtime/int: Warnings about using C number types instead of C++ ones
56-
# build/include_subdir: Warnings about prefacing included header files with directory
57-
58-
fi
59-
6040
### CODE ###
6141
if [[ -z "$CHECK" || "$CHECK" == "code" ]]; then
6242

doc/source/development/contributing_codebase.rst

+4-5
Original file line numberDiff line numberDiff line change
@@ -23,11 +23,10 @@ contributing them to the project::
2323

2424
./ci/code_checks.sh
2525

26-
The script verifies the linting of code files, it looks for common mistake patterns
27-
(like missing spaces around sphinx directives that make the documentation not
28-
being rendered properly) and it also validates the doctests. It is possible to
29-
run the checks independently by using the parameters ``lint``, ``patterns`` and
30-
``doctests`` (e.g. ``./ci/code_checks.sh lint``).
26+
The script validates the doctests, formatting in docstrings, static typing, and
27+
imported modules. It is possible to run the checks independently by using the
28+
parameters ``docstring``, ``code``, ``typing``, and ``doctests``
29+
(e.g. ``./ci/code_checks.sh doctests``).
3130

3231
In addition, because a lot of people use our library, it is important that we
3332
do not make sudden changes to the code that could have the potential to break

0 commit comments

Comments
 (0)