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

Uploaded Python 3Windows x86-64

typos-1.14.4-py3-none-win32.whl (2.5 MB view details)

Uploaded Python 3Windows x86

typos-1.14.4-py3-none-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (5.9 MB view details)

Uploaded Python 3manylinux: glibc 2.17+ x86-64

typos-1.14.4-py3-none-manylinux_2_17_i686.manylinux2014_i686.whl (5.1 MB view details)

Uploaded Python 3manylinux: glibc 2.17+ i686

typos-1.14.4-py3-none-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (7.0 MB view details)

Uploaded Python 3manylinux: glibc 2.17+ ARM64

typos-1.14.4-py3-none-macosx_11_0_arm64.whl (4.2 MB view details)

Uploaded Python 3macOS 11.0+ ARM64

typos-1.14.4-py3-none-macosx_10_7_x86_64.whl (4.2 MB view details)

Uploaded Python 3macOS 10.7+ x86-64

File details

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

File metadata

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

File hashes

Hashes for typos-1.14.4.tar.gz
Algorithm Hash digest
SHA256 01aca325bb41bc6a735ea3fff747b9942169081c28ab5d33844540ecdcac7627
MD5 d5e0d4bc4af14427d2fa06ca98b57d10
BLAKE2b-256 4781b6b1624953adb1adf99fb2a5246f6091684000da598f548c1238123b64ca

See more details on using hashes here.

File details

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

File metadata

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

File hashes

Hashes for typos-1.14.4-py3-none-win_amd64.whl
Algorithm Hash digest
SHA256 0b6e4b6377b087d5e530788672de0628c6c040d4706d0903f6fd83ce0885ccba
MD5 0ffe92d4a19e324dfa105879e933b643
BLAKE2b-256 bc14a08b4fb07934e82b5688c6203e4b807d9ca0f320a93b5433db2858ac0d22

See more details on using hashes here.

File details

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

File metadata

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

File hashes

Hashes for typos-1.14.4-py3-none-win32.whl
Algorithm Hash digest
SHA256 74344ac7993704e6b0b529932843ce47b34da08f89c3edac325d358c95ffaf1a
MD5 edf7d4895965755e3102e995720eb06a
BLAKE2b-256 0fee9257c445305000e203e2a4988e3e6962d5915ab318f35fc4e8a4e316a7e6

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for typos-1.14.4-py3-none-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 227628f0e6020b92f73863f1231ccd9d75fa74e80695ac93be1ab08b2fd7537e
MD5 87bbba49a0483509a35fced9dbd8d137
BLAKE2b-256 b9f309e9dd460ece3844763bec2896f35e1f6d7748aa1b9ef73972205de11372

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for typos-1.14.4-py3-none-manylinux_2_17_i686.manylinux2014_i686.whl
Algorithm Hash digest
SHA256 8053a23a7ba7f84e0ceacf89afdbd80b751dae9ad2b3ef88345487d121c92569
MD5 70efaff1e6e38d7c8a7e95b313779b27
BLAKE2b-256 35290b56020e8b4739eef5474b06105263ab5668c870ee73291c1d0db9433513

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for typos-1.14.4-py3-none-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 828fae5c4ffbd42866b3fcb4e9cdee9f63b4f0fa93c76ea9cdb978a40f96efc6
MD5 801f436bdbf76d86d1f59e60ccb8ff51
BLAKE2b-256 a46f45d494bf15ebb4f515777b547a0f1927aae9390008ce747f272cc9b7a678

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for typos-1.14.4-py3-none-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 a86c700fd285abebd2eb30eee2bd6cc3654f768f8d41a14a76f7e371b8696dd9
MD5 0b218febde332a3b5ccee13adb79f9e7
BLAKE2b-256 fe5d37ab2c010d79be27c26427beec68d602b2a978ff5c2b288ee5478c6fe6d2

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for typos-1.14.4-py3-none-macosx_10_7_x86_64.whl
Algorithm Hash digest
SHA256 52113d56e3008fd5d486a7ff4ab50ad51b5d952f53cbb5f2214ce8d7d41b5e8c
MD5 0d7a94ddc72b10ce00762a75b504e984
BLAKE2b-256 9d36befd23126fe3c486b2dd05b48b9058bbd83d91edc68210b666ebbfd26816

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