diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index b9fe5461aff37..e7a26a7905799 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -48,10 +48,6 @@ jobs: - name: Build Pandas uses: ./.github/actions/build_pandas - - name: Linting - run: ci/code_checks.sh lint - if: always() - - name: Checks on imported code run: ci/code_checks.sh code if: always() diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index d72364b66e0e7..892b8d6dfa0c8 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -107,6 +107,11 @@ repos: # Check for deprecated messages without sphinx directive |(DEPRECATED|DEPRECATE|Deprecated)(:|,|\.) types_or: [python, cython, rst] + - id: cython-casting + name: Check Cython casting is `obj`, not ` obj` + language: pygrep + entry: '[a-zA-Z0-9*]> ' + files: (\.pyx|\.pxi.in)$ - id: incorrect-backticks name: Check for backticks incorrectly rendering because of missing spaces language: pygrep diff --git a/ci/code_checks.sh b/ci/code_checks.sh index 0d05d50bd7dd6..f9860de3b2bb3 100755 --- a/ci/code_checks.sh +++ b/ci/code_checks.sh @@ -3,21 +3,18 @@ # Run checks related to code quality. # # This script is intended for both the CI and to check locally that code standards are -# respected. We are currently linting (PEP-8 and similar), looking for patterns of -# common mistakes (sphinx directives with missing blank lines, old style classes, -# unwanted imports...), we run doctests here (currently some files only), and we +# respected. We run doctests here (currently some files only), and we # validate formatting error in docstrings. # # Usage: # $ ./ci/code_checks.sh # run all checks -# $ ./ci/code_checks.sh lint # run linting only # $ ./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" == "code" || "$1" == "doctests" || "$1" == "docstrings" || "$1" == "typing" ]] || \ - { echo "Unknown command $1. Usage: $0 [lint|code|doctests|docstrings|typing]"; exit 9999; } +[[ -z "$1" || "$1" == "code" || "$1" == "doctests" || "$1" == "docstrings" || "$1" == "typing" ]] || \ + { echo "Unknown command $1. Usage: $0 [code|doctests|docstrings|typing]"; exit 9999; } BASE_DIR="$(dirname $0)/.." RET=0 @@ -40,23 +37,6 @@ if [[ "$GITHUB_ACTIONS" == "true" ]]; then INVGREP_PREPEND="##[error]" fi -### LINTING ### -if [[ -z "$CHECK" || "$CHECK" == "lint" ]]; then - - # Check that cython casting is of the form `obj` as opposed to ` obj`; - # it doesn't make a difference, but we want to be internally consistent. - # Note: this grep pattern is (intended to be) equivalent to the python - # regex r'(?])> ' - MSG='Linting .pyx code for spacing conventions in casting' ; echo $MSG - invgrep -r -E --include '*.pyx' --include '*.pxi.in' '[a-zA-Z0-9*]> ' pandas/_libs - RET=$(($RET + $?)) ; echo $MSG "DONE" - - # readability/casting: Warnings about C casting instead of C++ casting - # runtime/int: Warnings about using C number types instead of C++ ones - # build/include_subdir: Warnings about prefacing included header files with directory - -fi - ### CODE ### if [[ -z "$CHECK" || "$CHECK" == "code" ]]; then diff --git a/doc/source/development/contributing_codebase.rst b/doc/source/development/contributing_codebase.rst index 721b1af126709..53e66eeff51e6 100644 --- a/doc/source/development/contributing_codebase.rst +++ b/doc/source/development/contributing_codebase.rst @@ -23,11 +23,10 @@ contributing them to the project:: ./ci/code_checks.sh -The script verifies the linting of code files, it looks for common mistake patterns -(like missing spaces around sphinx directives that make the documentation not -being rendered properly) and it also validates the doctests. It is possible to -run the checks independently by using the parameters ``lint``, ``patterns`` and -``doctests`` (e.g. ``./ci/code_checks.sh lint``). +The script validates the doctests, formatting in docstrings, static typing, and +imported modules. It is possible to run the checks independently by using the +parameters ``docstring``, ``code``, ``typing``, and ``doctests`` +(e.g. ``./ci/code_checks.sh doctests``). In addition, because a lot of people use our library, it is important that we do not make sudden changes to the code that could have the potential to break