From dd7d290468958f3d2b88f447406359703b3cd8d6 Mon Sep 17 00:00:00 2001 From: Marco Gorelli Date: Fri, 16 Oct 2020 02:23:03 +0100 Subject: [PATCH] CI move check incorrect sphinx directives to pre-commit (#37136) --- .pre-commit-config.yaml | 11 ++++++++++- ci/code_checks.sh | 4 ---- pandas/core/generic.py | 2 +- 3 files changed, 11 insertions(+), 6 deletions(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 1c6d36133f0673..e6b021133dd90e 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -53,6 +53,15 @@ repos: types: [rst] args: [--filename=*.rst] additional_dependencies: [flake8-rst==0.7.0, flake8==3.7.9] + - id: incorrect-sphinx-directives + name: Check for incorrect Sphinx directives + language: pygrep + entry: >- + \.\. (autosummary|contents|currentmodule|deprecated + |function|image|important|include|ipython|literalinclude + |math|module|note|raw|seealso|toctree|versionadded + |versionchanged|warning):[^:] + files: \.(py|pyx|rst)$ - repo: https://github.com/asottile/yesqa rev: v1.2.2 hooks: @@ -61,4 +70,4 @@ repos: rev: v3.2.0 hooks: - id: end-of-file-fixer - exclude: '.html$|^LICENSES/|.csv$|.txt$|.svg$|.py$' + exclude: ^LICENSES/|\.(html|csv|txt|svg|py)$ diff --git a/ci/code_checks.sh b/ci/code_checks.sh index c8718128e4cc8b..62281146f5b553 100755 --- a/ci/code_checks.sh +++ b/ci/code_checks.sh @@ -202,10 +202,6 @@ if [[ -z "$CHECK" || "$CHECK" == "patterns" ]]; then invgrep -R --include="*.rst" -E "[a-zA-Z0-9]\`\`?[a-zA-Z0-9]" doc/source/ RET=$(($RET + $?)) ; echo $MSG "DONE" - MSG='Check for incorrect sphinx directives' ; echo $MSG - invgrep -R --include="*.py" --include="*.pyx" --include="*.rst" -E "\.\. (autosummary|contents|currentmodule|deprecated|function|image|important|include|ipython|literalinclude|math|module|note|raw|seealso|toctree|versionadded|versionchanged|warning):[^:]" ./pandas ./doc/source - RET=$(($RET + $?)) ; echo $MSG "DONE" - # Check for the following code in testing: `unittest.mock`, `mock.Mock()` or `mock.patch` MSG='Check that unittest.mock is not used (pytest builtin monkeypatch fixture should be used instead)' ; echo $MSG invgrep -r -E --include '*.py' '(unittest(\.| import )mock|mock\.Mock\(\)|mock\.patch)' pandas/tests/ diff --git a/pandas/core/generic.py b/pandas/core/generic.py index ad6e89ac74a5c7..f532060f68fc6e 100644 --- a/pandas/core/generic.py +++ b/pandas/core/generic.py @@ -5343,7 +5343,7 @@ def __finalize__( A passed method name providing context on where ``__finalize__`` was called. - .. warning: + .. warning:: The value passed as `method` are not currently considered stable across pandas releases.