8000 [MNT]: Add codespell to pre-commit hooks · Issue #22740 · matplotlib/matplotlib · GitHub
[go: up one dir, main page]

Skip to content

[MNT]: Add codespell to pre-commit hooks #22740

New issue

Have a question a 8000 bout 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

Closed
matthewfeickert opened this issue Mar 31, 2022 · 1 comment · Fixed by #22777
Closed

[MNT]: Add codespell to pre-commit hooks #22740

matthewfeickert opened this issue Mar 31, 2022 · 1 comment · Fixed by #22777
Milestone

Comments

@matthewfeickert
Copy link
Contributor
matthewfeickert commented Mar 31, 2022

Summary

In PR #22733 @QuLogic caught a spelling error of mine (which is great!) but there will inevitably be typos that slip through if only humans are checking. https://github.com/codespell-project/codespell is a really nice way to check for typos and it has a nice pre-commit hook. As Matplotlib already uses pre-commit 🚀 (thanks to @ianhi in PR #21583) this would be an easy add. 👍

Proposed fix

Add the following hook (maybe some variations) to .pre-commit-config.yaml

  - repo: https://github.com/codespell-project/codespell
    rev: v2.1.0
    hooks:
      - id: codespell
        files: ^.*\.(py|c|h|md|rst|yml)$
        args: ["--write-changes", "--ignore-words-list", "hist,nd"]
@matthewfeickert
Copy link
Contributor Author
matthewfeickert commented Mar 31, 2022

Okay, so I have this working on my fork. To get things passing so that

$ pre-commit run codespell --all-files
codespell................................................................Passed

passes I ended up using the --ignore-words option with corresponding file

$ cat codespell-ignore-words.txt 
ans
axises
ba
cannotation
coo
curvelinear
flate
hist
inout
ment
nd
oly
ot
sur
te
thisy
whis
wit

Matplotlib has a lot of abbreviations in the codebase that end up triggering some of these.

@timhoffm @QuLogic @ianhi two questions that I figured you might have thoughts on given PR #21583:

  • Is the addition of a config file for a pre-commit hook something that you think the dev team would be open to? If so, is there a location other than the top lev 8EF9 el of the repo that would be a more appropriate location? Maybe the ci/ dir?
  • If the reason for all the words in the codespell-ignore-words.txt file is documented in the commit message do you think that would be sufficient? Or would people want to know exactly why these words are in this file by reading another file? It isn't possible to comment the codespell-ignore-words.txt with motivations for additions and have it still function.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants
0