77 lines
1.5 KiB
Markdown
77 lines
1.5 KiB
Markdown
# Typos
|
|
|
|
A quick guide on how to use [`typos`](https://github.com/crate-ci/typos) to find, fix, and ignore typos.
|
|
|
|
## Installation
|
|
|
|
```sh
|
|
# Replace `<version>` with the version installed in `dev/install-typos.sh`.
|
|
brew install typos-cli@<version>
|
|
|
|
```
|
|
|
|
See https://github.com/crate-ci/typos?tab=readme-ov-file#install for other installation methods.
|
|
|
|
## Finding typos
|
|
|
|
```sh
|
|
pre-commit run --all-files typos
|
|
```
|
|
|
|
## Fixing typos
|
|
|
|
You can fix typos either manually or by running the following command:
|
|
|
|
```sh
|
|
typos --write-changes [PATH]
|
|
```
|
|
|
|
## Ignoring false positives
|
|
|
|
There are two ways to ignore false positives:
|
|
|
|
### Option 1: Ignore a line/block containing false positives
|
|
|
|
This option is preferred if the false positive is a one-off.
|
|
|
|
```python
|
|
# Ignore a line containing a typo:
|
|
|
|
"<false_positive>" # spellchecker: disable-line
|
|
|
|
# Ignore a block containing typos:
|
|
|
|
# spellchecker: off
|
|
"<false_positive>"
|
|
"<another_false_positive>"
|
|
# spellchecker: on
|
|
```
|
|
|
|
### Option 2: Extend the ignore list in [`pyproject.toml`](../pyproject.toml)
|
|
|
|
This option is preferred if the false positive is common across multiple files/lines.
|
|
|
|
```toml
|
|
# pyproject.toml
|
|
|
|
[tool.typos.default]
|
|
extend-ignore-re = [
|
|
...,
|
|
"false_positive",
|
|
]
|
|
```
|
|
|
|
## Found a typo, but `typos` doesn't recognize it?
|
|
|
|
`typos` only recognizes typos that are in its dictionary.
|
|
If you find a typo that `typos` doesn't recognize,
|
|
you can extend the `extend-words` list in [`pyproject.toml`](../pyproject.toml).
|
|
|
|
```toml
|
|
# pyproject.toml
|
|
|
|
[tool.typos.default.extend-words]
|
|
...
|
|
mflow = "mlflow"
|
|
```
|