Pre-commit: Move codespell script to pre-commit
#88969
Closed
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.
Suggestion cannot be applied right now. Please check back later.
Makes it enabled by default in pre-commit hooks, which should help users catch typos.
Opening as a draft as I think this risks being a bother to users, as codespell can sometimes have false positives, and it won't let them commit before solving the false positive or adding it to the ignore list.
On the other hand I raised its quietness option, which means it no longer nags about potential issues that it spotted but refused to fix as those fixes are disabled by default (due to often being false positives). So the remaining "sure" fixes might not be too bad.
One option could be to add this but leave it opt-in, by using
stage: [manual]
, so it doesn't actually run automatically on pre-commit hooks. It then needs to be run manually withpre-commit run codespell --hook-stage manual
... seems a bit tedious too.Another drawback to the approach in this PR is that we lose the PR diff annotations on GitHub, but I'm not sure how useful they were as they were not blocking, and we still introduced typos regardless.
Edit: This may be a nicer approach to set the file exclude and words ignore lists: https://github.com/codespell-project/codespell/blob/master/pyproject-codespell.precommit-toml