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

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-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?

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.

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

Uploaded Python 3Windows x86-64

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

Uploaded Python 3Windows x86

typos-1.13.21-py3-none-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (5.7 MB view details)

Uploaded Python 3manylinux: glibc 2.17+ x86-64

typos-1.13.21-py3-none-manylinux_2_17_i686.manylinux2014_i686.whl (4.9 MB view details)

Uploaded Python 3manylinux: glibc 2.17+ i686

typos-1.13.21-py3-none-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (6.8 MB view details)

Uploaded Python 3manylinux: glibc 2.17+ ARM64

typos-1.13.21-py3-none-macosx_11_0_arm64.whl (4.0 MB view details)

Uploaded Python 3macOS 11.0+ ARM64

typos-1.13.21-py3-none-macosx_10_7_x86_64.whl (4.0 MB view details)

Uploaded Python 3macOS 10.7+ x86-64

File details

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

File metadata

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

File hashes

Hashes for typos-1.13.21.tar.gz
Algorithm Hash digest
SHA256 964324756f94aee8e71289adaab1418f050dc2ba4582fc5738e4be2666da2ce2
MD5 5e3281113fcc209df8fd8b71b41788c0
BLAKE2b-256 f8db4f7fb7bdbea48fa22f734bc8d83f024e3bfbce10c40a7de36c06261b8e8b

See more details on using hashes here.

File details

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

File metadata

  • Download URL: typos-1.13.21-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/0.14.15

File hashes

Hashes for typos-1.13.21-py3-none-win_amd64.whl
Algorithm Hash digest
SHA256 c24f953df061940fe177a1a43ceb795eaf04acf28de8399fbbd96730f8e184e5
MD5 905670a0a6d39e135cc1558fea7e256e
BLAKE2b-256 26594885d6069f8134723baf5ae4902c2763c2ae86e229da14e9418ab5799261

See more details on using hashes here.

File details

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

File metadata

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

File hashes

Hashes for typos-1.13.21-py3-none-win32.whl
Algorithm Hash digest
SHA256 057660c31fd1b80740d77548b00a25dbc7601a5e98d0f7b120679fc58820570e
MD5 82fc8c60a28dc0bdfacc2e9fa88cf0db
BLAKE2b-256 03042c04b6ae9c298d3c2d8f43479c10999fee63b265ee7e9b86de77695aba07

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for typos-1.13.21-py3-none-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 666eb018a91676df1c34494b1f75212a8dbd6d8a627b73c2e05b000ccc5fcb01
MD5 121292d073e33fb0eeb11eee0241a9bb
BLAKE2b-256 6d834a0ecb06e90ae40bc96452a9e925d4652a601946e79a6d72fcfd7109e2fa

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for typos-1.13.21-py3-none-manylinux_2_17_i686.manylinux2014_i686.whl
Algorithm Hash digest
SHA256 eede0acaa97d17c66c079f1cc6eb8f75549ff42f5afdc86874c8e50f6a3dc100
MD5 117cb376702e04d795f3785d23244c71
BLAKE2b-256 7175099a9a2112a1d94063c2ffc174b11fb40e0721e4bfb8b34fa8523ae33760

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for typos-1.13.21-py3-none-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 bea007000713476c7a0c98fdb0bf00639d74d0cf627c18c6eb9ca3b772094b2c
MD5 72e86c2c497b690a96e85fcdb9f8382a
BLAKE2b-256 dd2f17ff0ba8332fcf9238586ed3cae3a32a4a0107fa6bfd48276658e5b0e0fe

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for typos-1.13.21-py3-none-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 4e2e089a4d5e5e4b70833d6a793131539c45073eec60ec9b573bb039e5cb8d38
MD5 862e149c43221a15ddac82b9ea953223
BLAKE2b-256 118a9d7602267dbcde90a96aa7cee09639bd9cc491e774b9f34a6690a4454fdd

See more details on using hashes here.

File details

Details for the file typos-1.13.21-py3-none-macosx_10_7_x86_64.whl.

File metadata

File hashes

Hashes for typos-1.13.21-py3-none-macosx_10_7_x86_64.whl
Algorithm Hash digest
SHA256 1ba18c8e4a6e9e2c7ab2e90d3ea99342e26d4456825732ba62780ba25388c68b
MD5 30732dabb76e9f74109d774acd1f2144
BLAKE2b-256 7b2dc91375bc0599be8604e43d621c8d9f7f36697af11c0a9a1cfee09e8d7fe2

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