CI: Add a spellchecker to pre-commit
Isn't there linters that we can run in CI to catch typos like that?
I don't think we have a spellchecker added to pre-commit, would be nice to add indeed
Originally posted by @leofang in https://github.com/NVIDIA/cuda-python/pull/1041#discussion_r2396192985
FWIW, this has been working fine for pybind11 for a few years already:
https://github.com/pybind/pybind11/blob/4dc33d652478e11a1e9b8ba6558d2fbd04a1bee0/.pre-commit-config.yaml#L111-L119
We had to add a suppressions file when we got started:
https://github.com/pybind/pybind11/blob/4dc33d652478e11a1e9b8ba6558d2fbd04a1bee0/.codespell-ignore-lines
Luckily the maintenance burden for that turned out to be very low. Once the spell checker is established, people tend to avoid variable names etc that would make it necessary to add more suppressions.
I'd like to take this. Proposed approach, based on the pybind11 setup linked above:
- Add a pinned codespell hook (v2.4.3) to
.pre-commit-config.yaml. - Exclude
cuda_bindings_12/andcuda_bindings_13/(about 560 hits there, mostly in generated code and API docs, which would need fixing in the generator inputs rather than by hand), vendored code, andpixi.lockfiles. - Ignore a few domain terms with
--ignore-words-list(ccompiler,lod,optin,vas) and one intentional spelling inline (theSUPPOREDenum alias comment incuda_core/tests/test_enum_coverage.py). - Fix the 31 typos it reports in the remaining files: comments, docstrings, old release notes, two CI step names, and samples. No code behavior changes.
I have this on a local branch. With the hook added, pre-commit run codespell --all-files fails on current main and passes with the fixes. The other pre-commit hooks pass on the changed files; I did not run lychee, trufflehog, or mypy-cuda-core locally.
If this scope works, could a maintainer assign this to me? I can also adjust it, for example by splitting the typo fixes into a separate PR or moving the settings into a config file.
This was investigated and written with an AI coding agent (Claude) working on my behalf.