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

Uploaded Python 3Windows x86-64

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

Uploaded Python 3Windows x86

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

Uploaded Python 3musllinux: musl 1.2+ x86-64

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

Uploaded Python 3musllinux: musl 1.2+ ARM64

typos-1.16.19-py3-none-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (6.4 MB view details)

Uploaded Python 3manylinux: glibc 2.17+ x86-64

typos-1.16.19-py3-none-manylinux_2_17_i686.manylinux2014_i686.whl (5.4 MB view details)

Uploaded Python 3manylinux: glibc 2.17+ i686

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

Uploaded Python 3manylinux: glibc 2.17+ ARM64

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

Uploaded Python 3macOS 11.0+ ARM64

typos-1.16.19-py3-none-macosx_10_7_x86_64.whl (4.4 MB view details)

Uploaded Python 3macOS 10.7+ x86-64

File details

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

File metadata

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

File hashes

Hashes for typos-1.16.19.tar.gz
Algorithm Hash digest
SHA256 ec1edd518c13032c304e7c5746a83971abe878b5f606903a7e6cfabd52c3d850
MD5 9930afefa9d344ad3b92a0f0d50525f1
BLAKE2b-256 af7ebb27b2320977a0a8fdf0317fcaeb46a695c9f71260df9b958167964b2762

See more details on using hashes here.

File details

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

File metadata

  • Download URL: typos-1.16.19-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.3.0

File hashes

Hashes for typos-1.16.19-py3-none-win_amd64.whl
Algorithm Hash digest
SHA256 313e4fa94b4402d2be4fb785be16165ef1a53d3d96653c516ee725ff03d3f6cd
MD5 9e32f5876374cb6f10823899314e8106
BLAKE2b-256 5cc3cb969d6caa72dc444fb51482c017a7e8a0af170893b7ead407b45c980ee9

See more details on using hashes here.

File details

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

File metadata

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

File hashes

Hashes for typos-1.16.19-py3-none-win32.whl
Algorithm Hash digest
SHA256 7f6a290d106f04f0c57afd5ba0f3da8572c9e7e6ce228b5a4b06ebf5f5e8fa43
MD5 b8885c461db0038c82bb0198abc89280
BLAKE2b-256 986d3c4185be2c792510b9781ed0ef6374eb1fba6e250e76f4996c7bcc49c511

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for typos-1.16.19-py3-none-musllinux_1_2_x86_64.whl
Algorithm Hash digest
SHA256 7332d1b9c898775cb0d03f73b7626968111096818a7ac09b385de52e9629d8e7
MD5 d2f3e48c7e235f7659b501f340358478
BLAKE2b-256 83a1ad538a3f55243bb1f585715b41f8ada50b91a463e23b163c35c805bb1445

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for typos-1.16.19-py3-none-musllinux_1_2_aarch64.whl
Algorithm Hash digest
SHA256 2661844bfae128a39c4d284bcc3291a0ca4398b670871317b2fcd315b4f72414
MD5 222ccc16824804631d2705f4cc53ff6b
BLAKE2b-256 dd5b7512a97d9dbfc47b225d069d1d761fb04e5734228bfcba50126ce3ffd8d7

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for typos-1.16.19-py3-none-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 db42b30cde95052617244b22be7a1887faec1c6dfaee55d49e3b78addbc10b0d
MD5 84abbeb0a0e037d5c1da6ae9b49c803f
BLAKE2b-256 50b509bd1a102481eb5a64d820c57db9bf8f3f15f8817b7ede5bb0c4c40dacbc

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for typos-1.16.19-py3-none-manylinux_2_17_i686.manylinux2014_i686.whl
Algorithm Hash digest
SHA256 e79ff0f030129f3a114beaa9a5c5aac92a636adc1649334fb885b7c3f052a9d7
MD5 f742c507328fa114453c3f5526fd73ed
BLAKE2b-256 642c91f9326bc55c1ef1de7d6ee5e0e726d2d1a5ead7beec7834ea3415019d1b

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for typos-1.16.19-py3-none-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 6e55221fe72821bc16b8e861adb73ad000ca5a2ffeccaba78d453342a3741f72
MD5 d0357402c2264d400a121d0553667a50
BLAKE2b-256 0623c3154872234fed4f8c3f7dfa62d9baa0979bc560a7dfa3122b85c1c254a6

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for typos-1.16.19-py3-none-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 96d03d30c2c2a3cb230bca84444739beca20b42a1844b511a27ac71e3d8e25a8
MD5 b00e06e19f7147a92cd1f4347ea911af
BLAKE2b-256 872ef91da1ec4d97500f46fa4386086ae06092a4e734ba37731061ebcb91bbcf

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for typos-1.16.19-py3-none-macosx_10_7_x86_64.whl
Algorithm Hash digest
SHA256 75e8721d737c307915c7aaf97d3395b97ce9b930e72c70974b9045c0da551dba
MD5 27cd8f64785e1ab5014bb48c1f79ebe6
BLAKE2b-256 84ff78626d0962757cfbb28f784faf0797af76b996bcf03c1b67b9909f6683c5

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