From 2973ba05d6ef228ff1ba378870e1bc299e4c01e5 Mon Sep 17 00:00:00 2001 From: Marco Gorelli Date: Thu, 15 Oct 2020 14:12:11 +0100 Subject: [PATCH 1/7] move check incorrect sphinx directives to pre-commit --- .pre-commit-config.yaml | 5 +++++ ci/code_checks.sh | 4 ---- pandas/core/generic.py | 2 +- 3 files changed, 6 insertions(+), 5 deletions(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 1c6d36133f067..d7d8ec9d5a9c1 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -53,6 +53,11 @@ 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 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)$ - repo: https://github.com/asottile/yesqa rev: v1.2.2 hooks: diff --git a/ci/code_checks.sh b/ci/code_checks.sh index 784d2c9a411ab..7d1a52ce0983e 100755 --- a/ci/code_checks.sh +++ b/ci/code_checks.sh @@ -214,10 +214,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 ad6e89ac74a5c..f532060f68fc6 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. From 59c5b15f737d5f80d50392fdea37e28b53e8a04c Mon Sep 17 00:00:00 2001 From: Marco Gorelli Date: Thu, 15 Oct 2020 14:18:05 +0100 Subject: [PATCH 2/7] fixup --- .pre-commit-config.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index d7d8ec9d5a9c1..70abfb3137625 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -54,7 +54,7 @@ repos: args: [--filename=*.rst] additional_dependencies: [flake8-rst==0.7.0, flake8==3.7.9] - id: incorrect-sphinx-directives - name: Check for incorrect Sphinx 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)$ From 21edba52a8e9331ea1b1a3f301fbb228470b6cc0 Mon Sep 17 00:00:00 2001 From: Marco Gorelli Date: Thu, 15 Oct 2020 14:21:17 +0100 Subject: [PATCH 3/7] :art: multiline yaml --- .pre-commit-config.yaml | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 70abfb3137625..d062036a4f9aa 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -56,7 +56,11 @@ repos: - 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):[^:]' + entry: >- + \.\. (autosummary|contents|currentmodule|deprecated + |function|image|important|include|ipython|literalinclude + |math|module|note|raw|seealso|toctree|versionadded + |versionchanged|warning):[^:] files: .(py|pyx)$ - repo: https://github.com/asottile/yesqa rev: v1.2.2 From 2c32a60252e9593efa0a269a5e8a7e7bcd67fc94 Mon Sep 17 00:00:00 2001 From: Marco Gorelli Date: Thu, 15 Oct 2020 15:07:16 +0100 Subject: [PATCH 4/7] Update .pre-commit-config.yaml --- .pre-commit-config.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index d062036a4f9aa..e9ee4ba1ed5ed 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -61,7 +61,7 @@ repos: |function|image|important|include|ipython|literalinclude |math|module|note|raw|seealso|toctree|versionadded |versionchanged|warning):[^:] - files: .(py|pyx)$ + files: .(py|pyx|rst)$ - repo: https://github.com/asottile/yesqa rev: v1.2.2 hooks: From e8bc5ee162eb576daa7f1d94ce6ce01cd01bc2f5 Mon Sep 17 00:00:00 2001 From: Marco Gorelli Date: Thu, 15 Oct 2020 15:17:32 +0100 Subject: [PATCH 5/7] escape --- .pre-commit-config.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index e9ee4ba1ed5ed..0a3ecb6de29ad 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -61,7 +61,7 @@ repos: |function|image|important|include|ipython|literalinclude |math|module|note|raw|seealso|toctree|versionadded |versionchanged|warning):[^:] - files: .(py|pyx|rst)$ + files: \.(py|pyx|rst)$ - repo: https://github.com/asottile/yesqa rev: v1.2.2 hooks: From 9923a3ac947c51eb7108c3444edd459aaefa6a35 Mon Sep 17 00:00:00 2001 From: Marco Gorelli Date: Thu, 15 Oct 2020 15:22:51 +0100 Subject: [PATCH 6/7] unify style of exclusions and files --- .pre-commit-config.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 0a3ecb6de29ad..3912505f04313 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -70,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) From 5efd53597195c14bdc8cc674a24cee7d19951208 Mon Sep 17 00:00:00 2001 From: Marco Gorelli Date: Thu, 15 Oct 2020 15:23:47 +0100 Subject: [PATCH 7/7] end of string --- .pre-commit-config.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 3912505f04313..e6b021133dd90 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -70,4 +70,4 @@ repos: rev: v3.2.0 hooks: - id: end-of-file-fixer - exclude: ^LICENSES/|\.(html|csv|txt|svg|py) + exclude: ^LICENSES/|\.(html|csv|txt|svg|py)$