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

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.16.1.tar.gz (1.4 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.16.1-py3-none-win_amd64.whl (2.9 MB view details)

Uploaded Python 3Windows x86-64

typos-1.16.1-py3-none-win32.whl (2.7 MB view details)

Uploaded Python 3Windows x86

typos-1.16.1-py3-none-musllinux_1_2_x86_64.whl (6.4 MB view details)

Uploaded Python 3musllinux: musl 1.2+ x86-64

typos-1.16.1-py3-none-musllinux_1_2_aarch64.whl (6.1 MB view details)

Uploaded Python 3musllinux: musl 1.2+ ARM64

typos-1.16.1-py3-none-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (6.3 MB view details)

Uploaded Python 3manylinux: glibc 2.17+ x86-64

typos-1.16.1-py3-none-manylinux_2_17_i686.manylinux2014_i686.whl (5.3 MB view details)

Uploaded Python 3manylinux: glibc 2.17+ i686

typos-1.16.1-py3-none-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (7.4 MB view details)

Uploaded Python 3manylinux: glibc 2.17+ ARM64

typos-1.16.1-py3-none-macosx_11_0_arm64.whl (4.4 MB view details)

Uploaded Python 3macOS 11.0+ ARM64

typos-1.16.1-py3-none-macosx_10_7_x86_64.whl (4.5 MB view details)

Uploaded Python 3macOS 10.7+ x86-64

File details

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

File metadata

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

File hashes

Hashes for typos-1.16.1.tar.gz
Algorithm Hash digest
SHA256 88b1553e0aa1b2c56cb57ee5eab48fd9fe408c1ccf420675ae61f79facd3b15d
MD5 c3d147ed7ba289ae98bd2f99ee9bc22a
BLAKE2b-256 ae929f81aadf280b77239a409dab1920ebed22b167d92c9c6b2ae7b0fea0ced5

See more details on using hashes here.

File details

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

File metadata

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

File hashes

Hashes for typos-1.16.1-py3-none-win_amd64.whl
Algorithm Hash digest
SHA256 21519c0c5b717eeeb49aa4487e5f4ac1c88c73c4535986069741ecbc89a7d818
MD5 4ff60326bb90205e8de4dd11cb978e80
BLAKE2b-256 c4048d135ba50c7ea9b5aa206f43dbed08cef6f005d47b68694d382ab889bedd

See more details on using hashes here.

File details

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

File metadata

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

File hashes

Hashes for typos-1.16.1-py3-none-win32.whl
Algorithm Hash digest
SHA256 ce61b4f8fb04a035a186aadca18a5b5e6eafc323f490bfdd87df70efa7fba99a
MD5 13e92a7f3f9ed4377059c80bf93aaa63
BLAKE2b-256 a1cb9e8375f09c6caf46dc87c753ff796397b6ff948d7dda40fea0373c72e7d0

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for typos-1.16.1-py3-none-musllinux_1_2_x86_64.whl
Algorithm Hash digest
SHA256 fd4da506dec382257065c2d21e7ffadf28c931801cd4b512a489ecd2e23ec0bd
MD5 7f1cb79c2c5fbe3adc2120734dab3dcd
BLAKE2b-256 d173517edad2f521fee34ecd87dd73d21bbbba37d6a1a7fb4db5cdfc3cf30b7c

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for typos-1.16.1-py3-none-musllinux_1_2_aarch64.whl
Algorithm Hash digest
SHA256 b2caa32c47787be4fc6465d635f8075f3d2c0dd8d673cea2b153956c8f09bd9c
MD5 f570e5194f60b273b0825090332343bf
BLAKE2b-256 5cbc37eb4ade0692398ee9bb3946561c453906e2a32b6b6698c6ed061db1d8ff

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for typos-1.16.1-py3-none-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 aaaa599d15a969ae957ed025467e2218bfad363e95f0564b5ddf278addd39243
MD5 96eb99a7a69ed12221c9e4a2d383a71f
BLAKE2b-256 5ba083631fcd5c5b609bc54338d40e8963eff97425790202fe6a7006976aae14

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for typos-1.16.1-py3-none-manylinux_2_17_i686.manylinux2014_i686.whl
Algorithm Hash digest
SHA256 c44cea7a7617ee518632a4a05d7a6f7eeb463f114cebd641375a59a4a9115aaf
MD5 6d328c84067c225b763cfc4391bbff0a
BLAKE2b-256 a3c52bb705cedd9a80b051d7ac61204af15f6b79cd219eb126dd3ef902163974

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for typos-1.16.1-py3-none-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 82744651b44bace20c7fff9f85700192663c4552ca1404e95719ad40cada6b06
MD5 50e595c372c993e6dad7d3369bf9d7e5
BLAKE2b-256 1b0ce3ca2cbf56cc3c7187bd2c57028df6bdb3afbf150005bd70d338dfd48874

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for typos-1.16.1-py3-none-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 922790bc48660105eb4432adb7d5e602d66fe1494f8d54d5115da33568f35e67
MD5 cb0d0f077788bae3a54b571bb1fbd629
BLAKE2b-256 4ad7f3585b50814fada313df52b6dcd93eb8f32f96693eb1d0c4d1e19792ac29

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for typos-1.16.1-py3-none-macosx_10_7_x86_64.whl
Algorithm Hash digest
SHA256 fe0db4a62d5edf621ef0dbd4fe9f93fb28240e89ad291e19ea0f0168664e25b6
MD5 633f72a5374c32b7f3f5e01a99dbe4e5
BLAKE2b-256 fafbd1ee03c7602f74166a51101ff2332d5c2a0fc1dbceb5421f785a614d4d61

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