Add codespell to pre-commit checks #1717
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Back in October 2021, I created #1423 to fix a large number of spelling errors. I've noticed some spelling errors in commits since then, but doing what I did on my first pass is way too time-intensive to do regularly. However, I found out about codespell, which is used in some other open source projects. Instead of being a strict check against a dictionary, it uses rules to fix common mistakes. While it likely does not catch every error that a more complete spellcheck would, it produces much fewer false positives. Running it on the repository (which takes under a second) catches some errors I missed back in my previous pass, as well as some spelling errors that were added more recently. Adding it to the checks will make spelling errors more difficult to sneak in.
I put the configuration directly into
.pre-commit-config.yamlfor ease of development, but I notice that clang-format and yapf both have separate config files. codespell supports bothsetup.cfgand.codespellrcfiles for configuration. Should I put it in one of them instead? If so, any preference for one file over the other?I explicitly excluded three files that have been automatically generated and not meant for human consumption anyway. In addition, I explicitly excluded the word
unsupportfrom the check because it is used in 12 poorly worded error messages that can probably have their wording improved to be more grammatical. I don't think that change is important enough to make it into this PR, though.