Source Code Spelling Correction
Project description
typos
Source code spell checker
Finds and corrects spelling mistakes among source code:
- Fast enough to run on monorepos
- Low false positives so you can run on PRs
Dual-licensed under MIT or Apache 2.0
Documentation
- Installation
- Getting Started
- Reference
- FAQ
- Comparison with other spell checkers
- Projects using typos
- Benchmarks
- Design
- Contribute
- CHANGELOG
Install
Download a pre-built binary (installable via gh-install).
Or use rust to install:
cargo install typos-cli
Or use Homebrew to install:
brew install typos-cli
Or use Conda to install:
conda install typos
Getting Started
Most commonly, you'll either want to see what typos are available with
typos
Or have them fixed
typos --write-changes
typos -w
If there is any ambiguity (multiple possible corrections), typos
will just report it to the user and move on.
False-positives
Sometimes, what looks like a typo is intentional, like with people's names, acronyms, or localized content.
To mark a word or an identifier (grouping of words) as valid, add it your _typos.toml
by declaring itself as the valid spelling:
[default]
extend-ignore-identifiers-re = [
# *sigh* this just isn't worth the cost of fixing
"AttributeID.*Supress.*",
]
[default.extend-identifiers]
# *sigh* this just isn't worth the cost of fixing
AttributeIDSupressMenu = "AttributeIDSupressMenu"
[default.extend-words]
# Don't correct the surname "Teh"
teh = "teh"
For cases like localized content, you can disable spell checking of file contents while still checking the file name:
[type.po]
extend-glob = ["*.po"]
check-file = false
(run typos --type-list
to see configured file types)
If you need some more flexibility, you can completely exclude some files from consideration:
[files]
extend-exclude = ["localized/*.po"]
Integrations
Custom
typos
provides several building blocks for custom native integrations
-
reads fromstdin
,--write-changes
will be written tostdout
--diff
to provide a diff--format json
to get jsonlines with exit code 0 on no errors, code 2 on typos, anything else is an error.
Examples:
# Read file from stdin, write corrected version to stdout
typos - --write-changes
# Creates a diff of what would change
typos dir/file --diff
# Fully programmatic control
typos dir/file --format json
Debugging
You can see what the effective config looks like by running
typos --dump-config -
You can then see how typos is processing your project with
typos --files
typos --identifiers
typos --words
If you need to dig in more, you can enable debug logging with -v
FAQ
Why was ... not corrected?
tl;dr typos
doesn't know about it yet
typos
maintains a list of known typo corrections to keep the false positive
count low so it can safely run unassisted.
This is in contrast to most spell checking UIs people use where there is a known list of valid words. In this case, the spell checker tries to guess your intent by finding the closest-looking word. It then has a gauge for when a word isn't close enough and assumes you know best. The user has the opportunity to verify these corrections and explicitly allow or reject them.
For more on the trade offs of these approaches, see Design.
- To correct it locally, see also our False Positives documentation.
- To contribute your correction, see Contribute
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distributions
Hashes for typos-1.14.10-py3-none-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 63213c944e3f9fe6743625f2b71fef7087bd118ad726e48299aa66be0d78e269 |
|
MD5 | cb07fa9c08d1e70a0c1338a286864be9 |
|
BLAKE2b-256 | 03dc83fad79087ab21334a960c21326cd06093bc0c91971321a043799220c7bd |
Hashes for typos-1.14.10-py3-none-win32.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | addb581424a02e0612489d8c7f8febfc57a41ff1b658435b58bfc6e1f04305f9 |
|
MD5 | 070417a3b74e3bfcfecfc7351a3412a8 |
|
BLAKE2b-256 | f7edb5ed070ad1d9d202a58d2fed763d4225d73347cc12bd89674955006fc1b8 |
Hashes for typos-1.14.10-py3-none-musllinux_1_2_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 2e7ce0810ab37d153691b15a9be4c92a48c08e1c25de2b80fa994ca7857aa153 |
|
MD5 | b3cff0b7372f9fb123d5afaa1f1f6cfe |
|
BLAKE2b-256 | f75db1be67e04055463f20d21241a621251be416867ef97b73a29ac9dd6151df |
Hashes for typos-1.14.10-py3-none-musllinux_1_2_aarch64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 34256d87cc618f9f0697efd669d41a3ba33389332d670813371150b61d455746 |
|
MD5 | 0adb10586f120d4b072ef48018331c26 |
|
BLAKE2b-256 | 7aeb23484fa05eb58008df0b3d2850cd7116f0510906854f0998026aef454774 |
Hashes for typos-1.14.10-py3-none-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 3dce7b5a965a9309d4c3da59505051a537dc84b40742581b51b10f4d74f0d5e8 |
|
MD5 | c181fefea7e4d8c2490abae85fcb7dc4 |
|
BLAKE2b-256 | ae69c982d128e99233a3d6c65c6ee6af923a94e89d8aeb84eef122053c51ebae |
Hashes for typos-1.14.10-py3-none-manylinux_2_17_i686.manylinux2014_i686.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 8cd3b27b20bcd17162c8545f3d581b8ee0b55c6a7079fd5bbe1bd2b77cc56380 |
|
MD5 | c16f6ffbf659a15ce372b8bc0db74e7c |
|
BLAKE2b-256 | 7902acb862a86f9fd0a6b21e2b4bb854769a017be5c105715ac0a92ab8a91260 |
Hashes for typos-1.14.10-py3-none-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | be23e95505374a5604fe3039572acf90437bee0ae682a00c87e562389691f7a4 |
|
MD5 | c066bfd83f910f50e45992a54bad7f49 |
|
BLAKE2b-256 | 78145e5614f9f66051268c51f1999885794136197e623310a4415db15bbb5e69 |
Hashes for typos-1.14.10-py3-none-macosx_11_0_arm64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | df5bd8f2f1f55bd40c20053523f8097c0031993bddf97203b8c9ef1c98ef4b21 |
|
MD5 | cf5470827ef90f64eda8f1868493e642 |
|
BLAKE2b-256 | 39a82df5ea572b13f1553596b593bc1589a5d8fc0ec8a938514f30412e9db38a |
Hashes for typos-1.14.10-py3-none-macosx_10_7_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 9ae7cb30ef42e7d5c2a6862129af2637457fdc420a66ec89693ec08890ced69f |
|
MD5 | c5cd26a250cfbcadb5b38c8312dc2741 |
|
BLAKE2b-256 | cad9e058dfff9deb61e738a831724bb937c1db2a122465f27996c558e54a7757 |