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.0.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.0-py3-none-win_amd64.whl (2.5 MB view details)

Uploaded Python 3Windows x86-64

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

Uploaded Python 3Windows x86

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

Uploaded Python 3musllinux: musl 1.2+ x86-64

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

Uploaded Python 3musllinux: musl 1.2+ ARM64

typos-1.26.0-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.0-py3-none-manylinux_2_17_i686.manylinux2014_i686.whl (3.3 MB view details)

Uploaded Python 3manylinux: glibc 2.17+ i686

typos-1.26.0-py3-none-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (4.9 MB view details)

Uploaded Python 3manylinux: glibc 2.17+ ARM64

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

Uploaded Python 3macOS 11.0+ ARM64

typos-1.26.0-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.0.tar.gz.

File metadata

  • Download URL: typos-1.26.0.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.0.tar.gz
Algorithm Hash digest
SHA256 97f7bc943aafa040bca272cd5c0b679503876041898b7b99339c9604c0794786
MD5 6681d76817cf30fc9fa4691d0a9ee1c8
BLAKE2b-256 563112366747b17230a35ea8ff32e4df25264a7c2c4dadc9c3618f93b5288e3b

See more details on using hashes here.

File details

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

File metadata

  • Download URL: typos-1.26.0-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.0-py3-none-win_amd64.whl
Algorithm Hash digest
SHA256 f4157c7b778e2128121f65279fa763329556e12188d200828f3e38c3029a6764
MD5 c38955b4998671ddf9fa1394e34d31ae
BLAKE2b-256 fa49b1cd7a8842db5a7882c52b9a2e2aa1b441cf387903c46ba5f9bc57d2cf79

See more details on using hashes here.

File details

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

File metadata

  • Download URL: typos-1.26.0-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.0-py3-none-win32.whl
Algorithm Hash digest
SHA256 7488c7124ac52a66ed79e74bdd11248b87d295391937b833f64e45c6c6237c82
MD5 07e6849b61e70d510e467667385ec6e4
BLAKE2b-256 0c315ca0b61e6ab918c5f3f798a7a0d50707e69e7effb5751dd9552773556456

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for typos-1.26.0-py3-none-musllinux_1_2_x86_64.whl
Algorithm Hash digest
SHA256 e247246548c862e819ae541713471f60830020b051364fc6f216606945322427
MD5 04f6ce3101f72d88ba0cb56e355b5d0c
BLAKE2b-256 43586a742a4c336b2f1f16bbad3494309f75933a01c84ea876de289212746d45

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for typos-1.26.0-py3-none-musllinux_1_2_aarch64.whl
Algorithm Hash digest
SHA256 72412d456c1c4a1cac8dd7f56410fe14aad22ab883b49aba704cbdb58b5cda0e
MD5 4b9f9a93d8408092a170c1c8948a2cfd
BLAKE2b-256 0064d6b42815e0fa369aad0cfdc6e5562dbc5a1a6e10e0fa157859b20d7f8c65

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for typos-1.26.0-py3-none-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 775802bc32203a68c475e47fb9dfa69ffe427bd85d3e27b03baa5a455bc2b4de
MD5 3fc339b904ed887be991035f40c9d502
BLAKE2b-256 4802ed690a44d0e4a460fcb265291d80ce63515dc8fd945b494f6ddb13769737

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for typos-1.26.0-py3-none-manylinux_2_17_i686.manylinux2014_i686.whl
Algorithm Hash digest
SHA256 fb97608d6a77470bf36d378341c81ded61dd14a10baa15e46431e12688e3d504
MD5 2fe5c5e3eb2416c2ae6738cdd1ad4277
BLAKE2b-256 f567763c088576133744d3ea624d1a561047168798ff5e4f3bc5f4129c50540a

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for typos-1.26.0-py3-none-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 0f33cd305042642d6a0bdc5e09fa6338385a7cb608e1385fd2b6d22d482e2071
MD5 bedc826a1062d3e1d312629d06ab9946
BLAKE2b-256 ec89c90cb4ed438243ec5ed3372f4e89bad331273d430a56161321425b4a12fd

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for typos-1.26.0-py3-none-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 2c50b4094f2252f5b4552514776f455914ae619f6a7418de002af51d981aaa7a
MD5 2b668d9cbf8cba8d1771ff7df6bef18f
BLAKE2b-256 674aa050bfc524e61f01540f568000355192a9ace86ff92e6cea76ffe5a20ac9

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for typos-1.26.0-py3-none-macosx_10_12_x86_64.whl
Algorithm Hash digest
SHA256 4a49e389f89b7b53aaea5f956134317507ddd92a14d7ec380cb918390e04aac8
MD5 dd42d9d64c77d809114ff3881bc68ba7
BLAKE2b-256 e734f8b480187c7d849130db6a2bdf33ce770513af89a73d9ba1a4427c3ddfcf

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