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

Uploaded Python 3Windows x86-64

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

Uploaded Python 3Windows x86

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

Uploaded Python 3musllinux: musl 1.2+ x86-64

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

Uploaded Python 3musllinux: musl 1.2+ ARM64

typos-1.16.18-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.18-py3-none-manylinux_2_17_i686.manylinux2014_i686.whl (5.4 MB view details)

Uploaded Python 3manylinux: glibc 2.17+ i686

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

Uploaded Python 3manylinux: glibc 2.17+ ARM64

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

Uploaded Python 3macOS 11.0+ ARM64

typos-1.16.18-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.18.tar.gz.

File metadata

  • Download URL: typos-1.16.18.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.18.tar.gz
Algorithm Hash digest
SHA256 3270e50704c0929f8a19fa9ede48d573ce9a55eb9cdf90318f5db727784e0f42
MD5 4a7d2b5777af06303db80840190c1a3f
BLAKE2b-256 fcbc26693cb611a8fa150e5cf54cc30b0686faa2372ceeb6310f4325fd91af58

See more details on using hashes here.

File details

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

File metadata

  • Download URL: typos-1.16.18-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.18-py3-none-win_amd64.whl
Algorithm Hash digest
SHA256 a60d099d747ccaecf366c311165473eb2168bc53e0ee30101e427a5c4ddece07
MD5 04baf420f68852884d063464ce568a8e
BLAKE2b-256 d6a909255f1ce4e1a0c250e2a39173d483e914262f8202307df1d25b7947dc13

See more details on using hashes here.

File details

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

File metadata

  • Download URL: typos-1.16.18-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.18-py3-none-win32.whl
Algorithm Hash digest
SHA256 cfdfa45b21e850a16bbe9012e782ba2d9515dffa59ef9de7ae9513f6e4117409
MD5 1db4bb5490baf67e11c190a8c4e69caf
BLAKE2b-256 7bc055953b01bb797696bd211d6e569b7a01e4803c9b933ad5f488c9af8b63e9

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for typos-1.16.18-py3-none-musllinux_1_2_x86_64.whl
Algorithm Hash digest
SHA256 1f406d563846711845b83460260905dfcc24d04040e1bd69c684932e2c2dd9b1
MD5 5a0b8591d86384de9cf9a76f23fd1a3c
BLAKE2b-256 6a5fec09052221af8b8c011ed630df992a6a490e450158946a65eb549939a9d1

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for typos-1.16.18-py3-none-musllinux_1_2_aarch64.whl
Algorithm Hash digest
SHA256 813eadddd751fea1e3e54cc996393008e2a19af0cc7fda856ebba1932130887b
MD5 67b5dcd9950b370c9b3d46cd0eccb0fc
BLAKE2b-256 f0bda7c079faa62e98da95d9d8adf9c687970a1cb4f773246f5e505b2f9a9edd

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for typos-1.16.18-py3-none-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 6f5068f13c6969d84937b856aab85199bbf1ff623fff4e60494d3b1e3301690a
MD5 ac218bafcf3c4e7d9373d3ca5b664e22
BLAKE2b-256 fd27e66a38cb0460c837cd19ae85cefd49aa3b8b9eb89de9a50c0ca2e35dabd6

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for typos-1.16.18-py3-none-manylinux_2_17_i686.manylinux2014_i686.whl
Algorithm Hash digest
SHA256 62d1e0dda8378c383d3bcaf6f0d975d448bbbc756437991287edb3d01c98f0e1
MD5 9d8fb360900970a01b283a3f1ee7b3ea
BLAKE2b-256 08721906e83b62083ef1fa9c5e386330835fb802648dac4669b9b65df098e918

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for typos-1.16.18-py3-none-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 a30b1b731c115059ab53f73bf2ebf4f88ed7a7706a060048196de27429d53ba3
MD5 714b19bde88dd8fc65e03cdc59077276
BLAKE2b-256 c6653ed80ff8565aa893b72d995b2c36411ab40d011fce012a6c75d084d697fc

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for typos-1.16.18-py3-none-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 cd4997f882cfb6766735bb78498e1f4ec4ecd54c2f033df193f3f89cdbec59cf
MD5 ba248535bec6bead6775f4beb8d70fe9
BLAKE2b-256 8654c8927c418e2df3152d85d70bb14ba2dc09c8f14c33941b60646b7dc3f965

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for typos-1.16.18-py3-none-macosx_10_7_x86_64.whl
Algorithm Hash digest
SHA256 6311ae328086eafdcafbe12df11e6fe7731729801d11dfee43fd6034687ac076
MD5 31aa4832ad82483bbf5b4b0c31997b58
BLAKE2b-256 5dd39c0d341e68b51984772d94c3b5f956274a4b82f0aacf2a24b1053c542968

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