Skip to main content

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

Screenshot

codecov Documentation License Crates Status

Dual-licensed under MIT or Apache 2.0

Documentation

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

Or use Pacman to install:

sudo pacman -S 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 from stdin, --write-changes will be written to stdout
  • --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?

Does the file show up in typos --files? If not, check your config with typos --dump-config -. The [files] table controls how we walk files. If you are using files.extend-exclude, are you running into #593? If you are using files.ignore-vcs = true, is the file in your .gitignore but git tracks it anyways? Prefer allowing the file explicitly (see #909).

Does the identifier show up in typos --identifiers or the word show up in typos --words? If not, it might be subject to one of typos' heuristics for detecting non-words (like hashes) or unambiguous words (like words after a \ escape).

If it is showing up, likely 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.

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

typos-1.20.7.tar.gz (1.7 MB view details)

Uploaded Source

Built Distributions

If you're not sure about the file name format, learn more about wheel file names.

typos-1.20.7-py3-none-win_amd64.whl (3.0 MB view details)

Uploaded Python 3Windows x86-64

typos-1.20.7-py3-none-win32.whl (2.8 MB view details)

Uploaded Python 3Windows x86

typos-1.20.7-py3-none-musllinux_1_2_x86_64.whl (6.3 MB view details)

Uploaded Python 3musllinux: musl 1.2+ x86-64

typos-1.20.7-py3-none-musllinux_1_2_aarch64.whl (6.0 MB view details)

Uploaded Python 3musllinux: musl 1.2+ ARM64

typos-1.20.7-py3-none-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (6.2 MB view details)

Uploaded Python 3manylinux: glibc 2.17+ x86-64

typos-1.20.7-py3-none-manylinux_2_17_i686.manylinux2014_i686.whl (5.2 MB view details)

Uploaded Python 3manylinux: glibc 2.17+ i686

typos-1.20.7-py3-none-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (7.3 MB view details)

Uploaded Python 3manylinux: glibc 2.17+ ARM64

typos-1.20.7-py3-none-macosx_11_0_arm64.whl (4.6 MB view details)

Uploaded Python 3macOS 11.0+ ARM64

typos-1.20.7-py3-none-macosx_10_12_x86_64.whl (4.7 MB view details)

Uploaded Python 3macOS 10.12+ x86-64

File details

Details for the file typos-1.20.7.tar.gz.

File metadata

  • Download URL: typos-1.20.7.tar.gz
  • Upload date:
  • Size: 1.7 MB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: maturin/1.5.1

File hashes

Hashes for typos-1.20.7.tar.gz
Algorithm Hash digest
SHA256 69ebdba3d4c338c3562d5fd7566decdd9fdaec6b9b73e8e9f968836219508e67
MD5 3e585cf005bf3601bd8fb0e04fefd1dc
BLAKE2b-256 0ad0d10ebd021fbbfb08a176ff1ddb527455dff0d30156d8eea66d84325c8ccf

See more details on using hashes here.

File details

Details for the file typos-1.20.7-py3-none-win_amd64.whl.

File metadata

  • Download URL: typos-1.20.7-py3-none-win_amd64.whl
  • Upload date:
  • Size: 3.0 MB
  • Tags: Python 3, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: maturin/1.5.1

File hashes

Hashes for typos-1.20.7-py3-none-win_amd64.whl
Algorithm Hash digest
SHA256 908f306b1a328a1697aa0b613ea6d742ff993e047a819612c5af75dd052bd2d3
MD5 8a19d723f8445d9c83540270c04b4b30
BLAKE2b-256 bbe797369b8d5c5510c799ff79ca82f807cdab78c61de16b9eed5d435e14c690

See more details on using hashes here.

File details

Details for the file typos-1.20.7-py3-none-win32.whl.

File metadata

  • Download URL: typos-1.20.7-py3-none-win32.whl
  • Upload date:
  • Size: 2.8 MB
  • Tags: Python 3, Windows x86
  • Uploaded using Trusted Publishing? No
  • Uploaded via: maturin/1.5.1

File hashes

Hashes for typos-1.20.7-py3-none-win32.whl
Algorithm Hash digest
SHA256 3c1cebd574dabd18bf5327655536e71a2991421a10c44b757e159dca9b9fb030
MD5 81f1a3aad585eb928ff684162700c4f6
BLAKE2b-256 99745277cbe0898c0c904763ce5d21c89429d1ce3e24b87404af42879a0b5ddb

See more details on using hashes here.

File details

Details for the file typos-1.20.7-py3-none-musllinux_1_2_x86_64.whl.

File metadata

File hashes

Hashes for typos-1.20.7-py3-none-musllinux_1_2_x86_64.whl
Algorithm Hash digest
SHA256 9dd2225150df04fcd08222a9609849c086dfc03e7e75163741caf21ed2c416b4
MD5 8a9336cf90d6cf6fd2bd7dfd14edc50f
BLAKE2b-256 1ba75e7cf4d6ff2de2e5f1c2345cb51d673c80086fd70ad784aa0b6377e2f0c0

See more details on using hashes here.

File details

Details for the file typos-1.20.7-py3-none-musllinux_1_2_aarch64.whl.

File metadata

File hashes

Hashes for typos-1.20.7-py3-none-musllinux_1_2_aarch64.whl
Algorithm Hash digest
SHA256 91751c63c51dc672ce9ab03358a670f52094cc38d387758ea1012b9e7ef070cf
MD5 43fbe764807d2614fbb86da81499aec8
BLAKE2b-256 787edaa977c432cbff5ac73b5f196d86140c5aa76108a0094ea5fd703c136a0f

See more details on using hashes here.

File details

Details for the file typos-1.20.7-py3-none-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for typos-1.20.7-py3-none-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 8a5bd0333015ee791d434ef6cb7e2709b00cea2f49f7bac779229d9c4bb76885
MD5 c3fd5376feed1a8c45409eafce94f5b7
BLAKE2b-256 f97aaba2c37490cef86e0b1ea6252ff00ac3760a34c280dd61257d96157daeff

See more details on using hashes here.

File details

Details for the file typos-1.20.7-py3-none-manylinux_2_17_i686.manylinux2014_i686.whl.

File metadata

File hashes

Hashes for typos-1.20.7-py3-none-manylinux_2_17_i686.manylinux2014_i686.whl
Algorithm Hash digest
SHA256 1de25e744002e40871cd541e4aae7b3318ef8a1271df12e04f751325093b4456
MD5 8c58a5ab2314f8472c2eb6a06467058d
BLAKE2b-256 d2f34e7575d3730d4d46d449ceea74d20dcbc5c4769be13bf420249ea44d7c5e

See more details on using hashes here.

File details

Details for the file typos-1.20.7-py3-none-manylinux_2_17_aarch64.manylinux2014_aarch64.whl.

File metadata

File hashes

Hashes for typos-1.20.7-py3-none-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 d733fe514e24a85dc37913554d5c6b6c13b51377e15e1822adce98fdae7dcbce
MD5 9bdb76d247084c86ffb41d93c930ad09
BLAKE2b-256 22bbafb6b0f0a6bb2d0130cfb9522bbad7d825ddeed964996319ff7ac6c85439

See more details on using hashes here.

File details

Details for the file typos-1.20.7-py3-none-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for typos-1.20.7-py3-none-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 5788525c32a8bfd73f3e33f16035ff93d6c0a7eaab07e877611aca47ec62d290
MD5 c6fbbf89abc93ad054afc11230c1de54
BLAKE2b-256 1f0cdf1bf85e4d209938877d04f7adff0415705b5f45fcd4d78abe00e81d433c

See more details on using hashes here.

File details

Details for the file typos-1.20.7-py3-none-macosx_10_12_x86_64.whl.

File metadata

File hashes

Hashes for typos-1.20.7-py3-none-macosx_10_12_x86_64.whl
Algorithm Hash digest
SHA256 daa433a49dbd1688b016e67c1167872bdee7abf1188cc3853f9cbcb684fa0bd5
MD5 bc44c87867434840fceb6735cc76268a
BLAKE2b-256 cd8c3f979baacc282665bb8ea7b2def4c73d19219e12c6c642c24136fc749b1a

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page