From cd061aeef164b380ba7a4b7699679a38f87cb111 Mon Sep 17 00:00:00 2001 From: Henry Schreiner Date: Wed, 14 Jul 2021 16:49:13 -0400 Subject: [PATCH 1/2] style: pre-commit cleanup (#3111) * style: disallow PyTest (should be pytest) * style: cleanup spell checking a bit * style: add a few items to the .gitignore --- .gitignore | 2 ++ .pre-commit-config.yaml | 10 +++------- docs/changelog.rst | 2 +- tests/CMakeLists.txt | 2 +- 4 files changed, 7 insertions(+), 9 deletions(-) diff --git a/.gitignore b/.gitignore index 3f36b89e0..3cf4fbbda 100644 --- a/.gitignore +++ b/.gitignore @@ -41,3 +41,5 @@ pybind11Targets.cmake /.vscode /pybind11/include/* /pybind11/share/* +/docs/_build/* +.ipynb_checkpoints/ diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 133eb6df4..4b0a34916 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -92,12 +92,8 @@ repos: rev: v2.1.0 hooks: - id: codespell - name: codespell - description: Checks for common misspellings in text files. - entry: codespell - language: python - types: [text] - args: ["-q", "3", "--skip", "*.supp", "-L", "nd,ot,thist,readded"] + exclude: ".supp$" + args: ["-L", "nd,ot,thist"] # The original pybind11 checks for a few C++ style items - repo: local @@ -105,7 +101,7 @@ repos: - id: disallow-caps name: Disallow improper capitalization language: pygrep - entry: PyBind|Numpy|Cmake|CCache + entry: PyBind|Numpy|Cmake|CCache|PyTest exclude: .pre-commit-config.yaml - repo: local diff --git a/docs/changelog.rst b/docs/changelog.rst index d71fccc25..698b78c1a 100644 --- a/docs/changelog.rst +++ b/docs/changelog.rst @@ -226,7 +226,7 @@ Bug fixes: * Fix ``py::gil_scoped_acquire`` assert with CPython 3.9 debug build. `#2683 `_ -* Fix issue with a test failing on PyTest 6.2. +* Fix issue with a test failing on pytest 6.2. `#2741 `_ Warning fixes: diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt index 3729b5c7d..dc70038db 100644 --- a/tests/CMakeLists.txt +++ b/tests/CMakeLists.txt @@ -315,7 +315,7 @@ function(pybind11_enable_warnings target_name) endif() endif() - # Needs to be readded since the ordering requires these to be after the ones above + # Needs to be re-added since the ordering requires these to be after the ones above if(CMAKE_CXX_STANDARD AND CMAKE_CXX_COMPILER_ID MATCHES "Clang" AND PYTHON_VERSION VERSION_LESS 3.0) From c4b0dc7cdd9cd70acce65940305d039ef336fc23 Mon Sep 17 00:00:00 2001 From: Aaron Gokaslan Date: Wed, 14 Jul 2021 16:52:13 -0400 Subject: [PATCH 2/2] Add shellcheck style checking (#3114) --- .pre-commit-config.yaml | 5 +++++ tools/check-style.sh | 6 +++--- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 4b0a34916..c6f31b280 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -95,6 +95,11 @@ repos: exclude: ".supp$" args: ["-L", "nd,ot,thist"] +- repo: https://github.com/shellcheck-py/shellcheck-py + rev: v0.7.2.1 + hooks: + - id: shellcheck + # The original pybind11 checks for a few C++ style items - repo: local hooks: diff --git a/tools/check-style.sh b/tools/check-style.sh index f7af2a416..6d832523a 100755 --- a/tools/check-style.sh +++ b/tools/check-style.sh @@ -16,11 +16,11 @@ check_style_errors=0 IFS=$'\n' -found="$(grep '\<\(if\|for\|while\|catch\)(\|){' $@ -rn --color=always)" +found="$(grep '\<\(if\|for\|while\|catch\)(\|){' "$@" -rn --color=always)" if [ -n "$found" ]; then echo -e '\033[31;01mError: found the following coding style problems:\033[0m' check_style_errors=1 - echo "$found" | sed -e 's/^/ /' + echo "${found//^/ /}" fi found="$(awk ' @@ -34,7 +34,7 @@ last && /^\s*{/ { last="" } { last = /(if|for|while|catch|switch)\s*\(.*\)\s*$/ ? $0 : "" } -' $(find include -type f) $@)" +' "$(find include -type f)" "$@")" if [ -n "$found" ]; then check_style_errors=1 echo -e '\033[31;01mError: braces should occur on the same line as the if/while/.. statement. Found issues in the following files:\033[0m'