Skip to content

Commit a6609ab

Browse files
authored
docs: add typos in a tab, use it for our checking (#724)
1 parent 9b6ff44 commit a6609ab

File tree

5 files changed

+50
-17
lines changed

5 files changed

+50
-17
lines changed

.pre-commit-config.yaml

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -66,14 +66,11 @@ repos:
6666
types_or: [yaml, markdown, html, css, scss, javascript, json]
6767
args: [--prose-wrap=always]
6868

69-
- repo: https://github.com/codespell-project/codespell
70-
rev: "v2.4.1"
69+
- repo: https://github.com/crate-ci/typos
70+
rev: "v1.40.0"
7171
hooks:
72-
- id: codespell
72+
- id: typos
7373
exclude: ^Gemfile\.lock$
74-
additional_dependencies:
75-
- tomli; python_version<'3.11'
76-
args: ["-w"]
7774

7875
- repo: local
7976
hooks:

docs/pages/guides/gha_basic.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -206,7 +206,7 @@ actions have outputs, and bash actions can manually write to output:
206206
You can now refer to this step in a later step with
207207
`${{ steps.someid.something }}`. You also can get it from another job by using
208208
`${{ needs.<jobname>.outputs.something }}`. The `toJson()` function is useful
209-
for inputing JSON - you can even generate matrices dynamically this way!
209+
for inputting JSON - you can even generate matrices dynamically this way!
210210

211211
{% endraw %}
212212

docs/pages/guides/style.md

Lines changed: 40 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -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
772776
very helpful to quickly make corrections if you have a lot of them when first
773777
adding 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+
775810
You can also use a local pygrep check to eliminate common capitalization errors,
776811
such 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

docs/pages/principles/testing.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -168,7 +168,7 @@ import pytest
168168

169169

170170
@pytest.mark.slow
171-
def test_somthing_slow(): ...
171+
def test_something_slow(): ...
172172
```
173173

174174
To mark every test in a directory, add the following to the `conftest.py` in the
@@ -626,8 +626,8 @@ much more complex and difficult to read for new developers.
626626
## Diagnostic Tests
627627

628628
Diagnostic tests are used to verify the installation of a package. They should
629-
be runable on production systems, like when we need to ssh into a live server to
630-
troubleshoot problems.
629+
be runnable on production systems, like when we need to ssh into a live server
630+
to troubleshoot problems.
631631

632632
A diagnostic test suite may contain any combination of tests you deem pertinent.
633633
You could include all the unit tests, or a specific subset of them. You may want

pyproject.toml

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -195,7 +195,6 @@ ignore = [
195195
[tool.repo-review.ignore]
196196
RTD103 = "Using Ruby instead of Python for docs"
197197

198-
[tool.codespell]
199-
ignore-words-list = [
200-
"nd",
201-
]
198+
[tool.typos.default.extend-words]
199+
nd = "nd"
200+
sur = "sur"

0 commit comments

Comments
 (0)