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

Uploaded Python 3Windows x86-64

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

Uploaded Python 3Windows x86

typos-1.14.5-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.5-py3-none-manylinux_2_17_i686.manylinux2014_i686.whl (5.1 MB view details)

Uploaded Python 3manylinux: glibc 2.17+ i686

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

Uploaded Python 3manylinux: glibc 2.17+ ARM64

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

Uploaded Python 3macOS 11.0+ ARM64

typos-1.14.5-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.5.tar.gz.

File metadata

  • Download URL: typos-1.14.5.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.5.tar.gz
Algorithm Hash digest
SHA256 39a7ac598a6e8a5c63cbbdde3aea3399e3111284d10995f8557c3b3b4dfe8a31
MD5 35ef98cd30834914c455453b03ef483a
BLAKE2b-256 a86ff55ae518008ee04ef77bed2604d7e10207cdd6c8a9512a2c200a70b72154

See more details on using hashes here.

File details

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

File metadata

  • Download URL: typos-1.14.5-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.5-py3-none-win_amd64.whl
Algorithm Hash digest
SHA256 de60fc7e272cf375784f5b05ceb53d0463cc02b972e7ed479f83cd21824f0dcf
MD5 3ba27469f390cc84e833fe3f8a61136b
BLAKE2b-256 ae4049fbd40396c167bcc2635d6fba22461293cdf727458a181c52e2076c7983

See more details on using hashes here.

File details

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

File metadata

  • Download URL: typos-1.14.5-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.5-py3-none-win32.whl
Algorithm Hash digest
SHA256 30f92f39b976a64084c6384548c7ff43b27e1538b4277425604227cb16819e9c
MD5 91a1642d0892a45493740b57b6024414
BLAKE2b-256 24057ed51aad1bc2e7688a3b71358decad295e5e6bcd6e96775b86d20e62efa8

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for typos-1.14.5-py3-none-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 7ec8f025d1be6e221f124fa7fadef6da1c90cc7a26460533221329ab2ef92e77
MD5 c4efab0ea10038b8978a0e1973c962e0
BLAKE2b-256 4d48e7a0ac1ec00d46628015542fc5f349cf88279fe7234bd792d5a4ce27cd9b

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for typos-1.14.5-py3-none-manylinux_2_17_i686.manylinux2014_i686.whl
Algorithm Hash digest
SHA256 36c9d78da2289ef4b46db371413739ad65c272f1b105e0c594290eca7049ddef
MD5 b3dab7b865efb4d9045127ac4220fd42
BLAKE2b-256 0e997dc6f7bb3b81b32848f11ff874b610400678186891db560bb6c61e62fab9

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for typos-1.14.5-py3-none-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 15200f6cddc0e25a25a0071c28eb39d9c8afc9679130b1551eafcf65b22e513f
MD5 a776a19e0c4dd1afcb9569ac718ac052
BLAKE2b-256 c8d5d2eeb9a05968650f55c91882eaf92a3de2f991c225043cf209dd8eea576e

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for typos-1.14.5-py3-none-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 4b90e86a3d8d91870b5bc6d9d54cec04c6588c90c70d1aade6254e921d22a857
MD5 3fe86f359992297e0fa58fecda16973a
BLAKE2b-256 fa977a023100b94c5fad6f04ad42449368c96ee361888eff4c29e2400fa67770

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for typos-1.14.5-py3-none-macosx_10_7_x86_64.whl
Algorithm Hash digest
SHA256 16a931c1f380f691360230d3c559d74b1449f526023eec651c938a76e9af2ccd
MD5 a8815cfdc1de2e08d20e9f6933657635
BLAKE2b-256 04bbe75eaa042b2af54482f0efc9e785d1d4a1b7458ef7a481350c949064b1de

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