@@ -745,9 +745,13 @@ Make sure you list the highest version of Python you are testing with here.
745745# # Spelling
746746
747747{% rr PC160 %} You can and should check for spelling errors in your code too. If
748- you want to add this, you can use [codespell][] for common spelling mistakes.
749- Unlike most spell checkers, this has a list of mistakes it looks for, rather
750- than a list of "valid" words. To use :
748+ you want to add this, you can use a code-ready spell checker for common spelling
749+ mistakes. Unlike most spell checkers, these have a list of mistakes they look
750+ for, rather than a list of "valid" words. To use :
751+
752+ {% tabs spell %} {% tab codespell codespell %}
753+
754+ If you want a Python based tool, [codespell] is the classic tool used.
751755
752756` ` ` yaml
753757- repo: https://github.com/codespell-project/codespell
@@ -772,6 +776,37 @@ You can also add the `-w` flag to have it automatically correct errors - this is
772776very helpful to quickly make corrections if you have a lot of them when first
773777adding the check. `uvx codespell -w` will quickly correct all non-hidden files.
774778
779+ {% endtab %} {% tab typos typos %}
780+
781+ A rust rewrite of [codespell][], [typos][] has a defining feature : It can find
782+ typos in CamelCase or snake_case variable names. It also is probably faster,
783+ though codespell is very fast too. This one is not available on PyPI, use
784+ pre-commit, gh-install, brew, cargo, or conda/pixi. It also has LSP (VSCode)
785+ integration.
786+
787+ ` ` ` yaml
788+ - repo: https://github.com/crate-ci/typos
789+ rev: "v1.40.0"
790+ hooks:
791+ - id: typos
792+ args: []
793+ ` ` `
794+
795+ To configure it, you can use this section in `pyproject.toml` :
796+
797+ ` ` ` toml
798+ [tool.typos.default.extend-words]
799+ nd = "nd"
800+ sur = "sur"
801+ ` ` `
802+
803+ It has quite a few supported configuration options, like adding your own
804+ corrections, feel free to check the [full reference][typos-ref]. If you want it
805+ to write changes, you can remove the `args : []` in the pre-commit hook, or add
806+ ` -w` when running it locally.
807+
808+ {% endtab %} {% endtabs %}
809+
775810You can also use a local pygrep check to eliminate common capitalization errors,
776811such as the one below :
777812
@@ -992,6 +1027,8 @@ You also might like the following hook, which cleans Jupyter outputs:
9921027[check-jsonschema] : https://check-jsonschema.readthedocs.io/en/latest/
9931028[cjs-common] : https://check-jsonschema.readthedocs.io/en/latest/precommit_usage.html#supported-hooks
9941029[schemastore] : https://schemastore.org
1030+ [typos] : https://github.com/crate-ci/typos
1031+ [typos-ref] : https://github.com/crate-ci/typos/blob/master/docs/reference.md
9951032
9961033<!-- prettier-ignore-end -->
9971034
0 commit comments