From 55c4082ad0c735279ae68b7c0c4f6cdce37f91b0 Mon Sep 17 00:00:00 2001 From: Matthew Feickert Date: Wed, 30 Mar 2022 23:47:29 -0500 Subject: [PATCH 1/2] DEV: Add codespell to pre-commit hooks Add https://github.com/codespell-project/codespell as a pre-commit hook that checks for common misspellings of English words in files with the following extensions: .py, .c, .cpp, .h, .m, .md, .rst, .yml. Ignore instances of: * 'ans', 'axises', 'curvelinear', 'hist', 'nd', 'oly', 'thisy', 'wit' * 'ba' for bound axis and bound args * 'cannotation' for centered annotation * 'coo' for COO (Coordinate list) * 'flate' for Flate compression * 'inout' for lib/matplotlib/rcsetup.py * 'ment' for alignment with formatting * 'whis' for whikser plot * 'sur' for Big Sur * 'TE' for triangle elements and skip checking doc/users/project/credits.rst as the list of names of contributors isn't worth adding in to the ignore file to avoid false positives. --- .pre-commit-config.yaml | 11 +++++++++++ ci/codespell-ignore-words.txt | 17 +++++++++++++++++ 2 files changed, 28 insertions(+) create mode 100644 ci/codespell-ignore-words.txt diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index dcfdb7209a5b..04f8a02cb980 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -28,3 +28,14 @@ repos: - id: flake8 additional_dependencies: [pydocstyle>5.1.0, flake8-docstrings>1.4.0] args: ["--docstring-convention=all"] + - repo: https://github.com/codespell-project/codespell + rev: v2.1.0 + hooks: + - id: codespell + files: ^.*\.(py|c|cpp|h|m|md|rst|yml)$ + args: [ + "--ignore-words", + "ci/codespell-ignore-words.txt", + "--skip", + "doc/users/project/credits.rst" + ] diff --git a/ci/codespell-ignore-words.txt b/ci/codespell-ignore-words.txt new file mode 100644 index 000000000000..70366f6b3552 --- /dev/null +++ b/ci/codespell-ignore-words.txt @@ -0,0 +1,17 @@ +ans +axises +ba +cannotation +coo +curvelinear +flate +hist +inout +ment +nd +oly +sur +te +thisy +whis +wit From 20da81fdff90c67805bcfecfd4c93108891c2055 Mon Sep 17 00:00:00 2001 From: Matthew Feickert Date: Thu, 31 Mar 2022 16:39:30 -0500 Subject: [PATCH 2/2] FIX: Fix typo caught by codespell pre-commit hook --- lib/matplotlib/tests/test_cbook.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/matplotlib/tests/test_cbook.py b/lib/matplotlib/tests/test_cbook.py index cf2009c5a44a..872e9b9c39d9 100644 --- a/lib/matplotlib/tests/test_cbook.py +++ b/lib/matplotlib/tests/test_cbook.py @@ -420,7 +420,7 @@ def test_func2(): ('# only comment "with quotes" xx', ''), ]) def test_strip_comment(line, result): - """Strip everything from the first unqouted #.""" + """Strip everything from the first unquoted #.""" assert cbook._strip_comment(line) == result