Skip to content

DEV: Add codespell to pre-commit hooks #22777

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The list hopefully doesn't seem too excessive, but as Matplotlib has a lot of abbreviations of variables in it this is the minimum number of ignores needed to get codespell working when run across all of the above file types.

"--skip",
"doc/users/project/credits.rst"
]
17 changes: 17 additions & 0 deletions ci/codespell-ignore-words.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
ans
axises
ba
cannotation
coo
curvelinear
flate
hist
inout
ment
nd
oly
sur
te
thisy
whis
wit
2 changes: 1 addition & 1 deletion lib/matplotlib/tests/test_cbook.py
Original file line number Diff line number Diff line change
Expand Up @@ -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


Expand Down