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

Uploaded Python 3Windows x86-64

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

Uploaded Python 3Windows x86

typos-1.16.11-py3-none-musllinux_1_2_x86_64.whl (6.5 MB view details)

Uploaded Python 3musllinux: musl 1.2+ x86-64

typos-1.16.11-py3-none-musllinux_1_2_aarch64.whl (6.3 MB view details)

Uploaded Python 3musllinux: musl 1.2+ ARM64

typos-1.16.11-py3-none-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (6.5 MB view details)

Uploaded Python 3manylinux: glibc 2.17+ x86-64

typos-1.16.11-py3-none-manylinux_2_17_i686.manylinux2014_i686.whl (5.5 MB view details)

Uploaded Python 3manylinux: glibc 2.17+ i686

typos-1.16.11-py3-none-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (7.6 MB view details)

Uploaded Python 3manylinux: glibc 2.17+ ARM64

typos-1.16.11-py3-none-macosx_11_0_arm64.whl (4.6 MB view details)

Uploaded Python 3macOS 11.0+ ARM64

typos-1.16.11-py3-none-macosx_10_7_x86_64.whl (4.6 MB view details)

Uploaded Python 3macOS 10.7+ x86-64

File details

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

File metadata

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

File hashes

Hashes for typos-1.16.11.tar.gz
Algorithm Hash digest
SHA256 44e94672544f811cb07e753a57468e4a1bd828868b2b25a5a86b1d0f06de9b23
MD5 98981964ca24c38b85be9474f438c371
BLAKE2b-256 4a151ed4d709cd654504e06bf9d0cfe36503b8be6f80f9c79e618434862d2ddc

See more details on using hashes here.

File details

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

File metadata

  • Download URL: typos-1.16.11-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.2.3

File hashes

Hashes for typos-1.16.11-py3-none-win_amd64.whl
Algorithm Hash digest
SHA256 0c36c0b940a9d288edc25cea085b437df0e9dea1b2eb14bfc7a85b6984538f69
MD5 df6c72838f58eb633efd031d275ef20c
BLAKE2b-256 337cd9c40548fd27b1574dc8077f316955b7559f15602fb0001da2354adaebf0

See more details on using hashes here.

File details

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

File metadata

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

File hashes

Hashes for typos-1.16.11-py3-none-win32.whl
Algorithm Hash digest
SHA256 b64d6f0b77ca9389a3793a9758783670daa7e85e38b8391a98d1870c0b063519
MD5 ea49422b7701c8a935eee9d8e06d038a
BLAKE2b-256 10a509dd7c9e997ac5e4f8c392a0d4853f46f124653dd2055ebe42aaacb0bc17

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for typos-1.16.11-py3-none-musllinux_1_2_x86_64.whl
Algorithm Hash digest
SHA256 63b8ee9d45f147acb68070ea0ca46a2a2f8b8e7fcc09cb39d1977fa6db3d1959
MD5 7d29f50c73033c03aacbe60cd29d9e85
BLAKE2b-256 f6476f6aa7eb7b8127834c9b55a61183385d6ea5b5c83da33278acdbe185847e

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for typos-1.16.11-py3-none-musllinux_1_2_aarch64.whl
Algorithm Hash digest
SHA256 7282151b26d1c84c47b9bef2d91179ac0eb9ebc58c431ffbd7ec8fbfd2bdbd83
MD5 ec61b9ddbe00bcd5248e17004cedc224
BLAKE2b-256 1c8c12723369f51bc489da2880a97599e9a3a7bae54855c607340bdfc5cfa72b

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for typos-1.16.11-py3-none-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 ad94da00878fd53e9442ca3986f2d3edc1eb9321b54f41fcecaa1cec0a8b3dcb
MD5 9cdf9f16d54313f4d1c90980a7801319
BLAKE2b-256 b4c498a6211a5b66b01c4654e922e4ec4db04cbb58fe9c9e1069c04d486be5ba

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for typos-1.16.11-py3-none-manylinux_2_17_i686.manylinux2014_i686.whl
Algorithm Hash digest
SHA256 89f7c99b48ba34166a94e94d8e7e50c0fea503380e2e9bc8bb62bc6bb0d1a2fd
MD5 7c7a323257256ba7c7e96d2ecf487933
BLAKE2b-256 dda773f8b1c61d1d5408c73416ccc8eb2ba8a4ec26820b25ad9d917a5f2e0f68

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for typos-1.16.11-py3-none-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 b208f42c939a348802e26a45a45cac7200ee6225643106ba27fb91aee418be85
MD5 13738e960bb13cebf1200a54bf01ce76
BLAKE2b-256 3ab408c42d737af763167d2942b3d8056aa14498472258cc5a2332a5d9a18e6b

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for typos-1.16.11-py3-none-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 05edd33a13ef6a6a88016e6f367f3a4158989f397371bc1ca07d5b4c38c94262
MD5 58561dff6be3f737bd57e0c7330194fd
BLAKE2b-256 ebc353a0a2e0d86f18987cc46c4ec51c517de5754ee9556218cbee6e72f0c561

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for typos-1.16.11-py3-none-macosx_10_7_x86_64.whl
Algorithm Hash digest
SHA256 5996c347cab149904c2f2a3f6194982f03c20c5302f9ee4ab866f4e5be0efed8
MD5 ee5ca0c94c9781983903f410dabe896f
BLAKE2b-256 dbb6d0214922c290c6ee1b9de60845fcfa960d2946cb42eba76889935e84d026

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