/ dev / typos.md
typos.md
 1  # Typos
 2  
 3  A quick guide on how to use [`typos`](https://github.com/crate-ci/typos) to find, fix, and ignore typos.
 4  
 5  ## Installation
 6  
 7  ```sh
 8  # Replace `<version>` with the version installed in `dev/install-typos.sh`.
 9  brew install typos-cli@<version>
10  
11  ```
12  
13  See https://github.com/crate-ci/typos?tab=readme-ov-file#install for other installation methods.
14  
15  ## Finding typos
16  
17  ```sh
18  pre-commit run --all-files typos
19  ```
20  
21  ## Fixing typos
22  
23  You can fix typos either manually or by running the following command:
24  
25  ```sh
26  typos --write-changes [PATH]
27  ```
28  
29  ## Ignoring false positives
30  
31  There are two ways to ignore false positives:
32  
33  ### Option 1: Ignore a line/block containing false positives
34  
35  This option is preferred if the false positive is a one-off.
36  
37  ```python
38  # Ignore a line containing a typo:
39  
40  "<false_positive>"  # spellchecker: disable-line
41  
42  # Ignore a block containing typos:
43  
44  # spellchecker: off
45  "<false_positive>"
46  "<another_false_positive>"
47  # spellchecker: on
48  ```
49  
50  ### Option 2: Extend the ignore list in [`pyproject.toml`](../pyproject.toml)
51  
52  This option is preferred if the false positive is common across multiple files/lines.
53  
54  ```toml
55  # pyproject.toml
56  
57  [tool.typos.default]
58  extend-ignore-re = [
59    ...,
60    "false_positive",
61  ]
62  ```
63  
64  ## Found a typo, but `typos` doesn't recognize it?
65  
66  `typos` only recognizes typos that are in its dictionary.
67  If you find a typo that `typos` doesn't recognize,
68  you can extend the `extend-words` list in [`pyproject.toml`](../pyproject.toml).
69  
70  ```toml
71  # pyproject.toml
72  
73  [tool.typos.default.extend-words]
74  ...
75  mflow = "mlflow"
76  ```