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.26.4.tar.gz (1.1 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.26.4-py3-none-win_amd64.whl (2.5 MB view details)

Uploaded Python 3Windows x86-64

typos-1.26.4-py3-none-win32.whl (2.4 MB view details)

Uploaded Python 3Windows x86

typos-1.26.4-py3-none-musllinux_1_2_x86_64.whl (4.1 MB view details)

Uploaded Python 3musllinux: musl 1.2+ x86-64

typos-1.26.4-py3-none-musllinux_1_2_aarch64.whl (3.9 MB view details)

Uploaded Python 3musllinux: musl 1.2+ ARM64

typos-1.26.4-py3-none-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (4.1 MB view details)

Uploaded Python 3manylinux: glibc 2.17+ x86-64

typos-1.26.4-py3-none-manylinux_2_17_i686.manylinux2014_i686.whl (3.4 MB view details)

Uploaded Python 3manylinux: glibc 2.17+ i686

typos-1.26.4-py3-none-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (4.3 MB view details)

Uploaded Python 3manylinux: glibc 2.17+ ARM64

typos-1.26.4-py3-none-macosx_11_0_arm64.whl (2.9 MB view details)

Uploaded Python 3macOS 11.0+ ARM64

typos-1.26.4-py3-none-macosx_10_12_x86_64.whl (3.0 MB view details)

Uploaded Python 3macOS 10.12+ x86-64

File details

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

File metadata

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

File hashes

Hashes for typos-1.26.4.tar.gz
Algorithm Hash digest
SHA256 7a1e408eae411e0a4579e014310759894401bdadd3fa1403d432b80ba8387e25
MD5 4764336bac7a7b6f80c2a0ce30ba4448
BLAKE2b-256 ce36b83097c7e1ab9b1855ac9c0661b0350aedc014e6e3e9e3f6d7f1c7102ab6

See more details on using hashes here.

File details

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

File metadata

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

File hashes

Hashes for typos-1.26.4-py3-none-win_amd64.whl
Algorithm Hash digest
SHA256 1c39151ffdca0e54e41506b4280145c1cc68caefc2031f7e2b2e87dd67d3fee4
MD5 0a6b98c8aa2b659f6092e069eab529c4
BLAKE2b-256 7784bac802599b7b409207df271654807e3be51d2195b1650b724aedcd10f1cc

See more details on using hashes here.

File details

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

File metadata

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

File hashes

Hashes for typos-1.26.4-py3-none-win32.whl
Algorithm Hash digest
SHA256 96e583eb9fc23852794c55d430abd09de6665c83445f2d15c9901d58d90f261e
MD5 216d4b9f553bf3260e6ba9e1c10a32be
BLAKE2b-256 3e547e0a0d425d3dfe9feeb77d9b840ad4333ce52de3c46bbaec3e7c6ea51ea3

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for typos-1.26.4-py3-none-musllinux_1_2_x86_64.whl
Algorithm Hash digest
SHA256 2e53f35bafddabc686c2e40043da9d7ec5de3d83e19632df65eca80bb2137cd7
MD5 9fb35c56415e19fef1aeb66f7cdd3eba
BLAKE2b-256 243433853eaa59a3f086038aab978d3266e6fb4c928f1811111a64336214b8d8

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for typos-1.26.4-py3-none-musllinux_1_2_aarch64.whl
Algorithm Hash digest
SHA256 15c56fcc892b5f0b539b772108a120d6dcc41309bc055d27caccc96256a84e3f
MD5 324d600a51451bbde599d4269bfe4e3c
BLAKE2b-256 e4ae363b621c77d96b86b944facf444e23e33f189dd3bcb90479f86a82e2876a

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for typos-1.26.4-py3-none-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 4c5d754342254e3b32e426b7785dd1ce1f7c583b0c49ed9dbe160d3688a8a503
MD5 5163967a28bc9391fb7d1918f34965e7
BLAKE2b-256 b73291287105949bbd26ffea22ec2e08820d50c97de31f914d3b7d377eacb9b0

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for typos-1.26.4-py3-none-manylinux_2_17_i686.manylinux2014_i686.whl
Algorithm Hash digest
SHA256 af02d367ec44217a55ce002e83a74ece91b5d020b6b3ea6d1683afdef9e859fd
MD5 989c377e5ab5daae4fa61ac274660808
BLAKE2b-256 45caa3b92f138850f21df542aedb3c84c03f5952926ceb03197bd26ca278c8c2

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for typos-1.26.4-py3-none-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 80a5339cee77e43324c0332f4624decec0e9d3e49f52ad02c5a3e75673b2e39f
MD5 bb256c94145fd89fba7778ca2152162d
BLAKE2b-256 c56f3b54d26e5db0b5c321a955c2529decbc015ca0fafee3c2bdca5b8a51a259

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for typos-1.26.4-py3-none-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 452e685773e5a36060c7035cf630938519aff1316258f75223def1ef24ea30ac
MD5 d77f3ad8b5b146c7f93b9a7d9963633c
BLAKE2b-256 ac417e33f2795a8cf10ab49cf82369c85d416ef86ce58bc7ff021cb74102ce7c

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for typos-1.26.4-py3-none-macosx_10_12_x86_64.whl
Algorithm Hash digest
SHA256 2425c571136a5e75d7a9bbbd77d8c60be272006179bef15bed8798ab6488f8fc
MD5 80dafa4e3d6d1157ebe3eb64a0100e8a
BLAKE2b-256 c0e7217fc2e8d7bc245302da93f4a29bd12c7f4ce26ec3c938b7f1cfef57a411

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