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

Uploaded Python 3Windows x86-64

typos-1.14.1-py3-none-win32.whl (2.4 MB view details)

Uploaded Python 3Windows x86

typos-1.14.1-py3-none-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (5.7 MB view details)

Uploaded Python 3manylinux: glibc 2.17+ x86-64

typos-1.14.1-py3-none-manylinux_2_17_i686.manylinux2014_i686.whl (4.9 MB view details)

Uploaded Python 3manylinux: glibc 2.17+ i686

typos-1.14.1-py3-none-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (6.8 MB view details)

Uploaded Python 3manylinux: glibc 2.17+ ARM64

typos-1.14.1-py3-none-macosx_11_0_arm64.whl (4.0 MB view details)

Uploaded Python 3macOS 11.0+ ARM64

typos-1.14.1-py3-none-macosx_10_7_x86_64.whl (4.0 MB view details)

Uploaded Python 3macOS 10.7+ x86-64

File details

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

File metadata

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

File hashes

Hashes for typos-1.14.1.tar.gz
Algorithm Hash digest
SHA256 34ba7e815921799545bccc4b0f332ec018808e498f973e02876cc8db8951e328
MD5 2ef7808ac62191c6e22d8d8f15153545
BLAKE2b-256 5ab3a9e8a8fd122a45f727f21fd9d10a3d32359c8873e4e64f85ca32f976ccb6

See more details on using hashes here.

File details

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

File metadata

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

File hashes

Hashes for typos-1.14.1-py3-none-win_amd64.whl
Algorithm Hash digest
SHA256 d3c1e32b9e3a96925342d2303060fc37830a8a55446a27375ba20901260b6a23
MD5 83768394a0b7f2e02c97c7dd98c89a3e
BLAKE2b-256 e77dc147ae597c40c5c6e40d26fde71ecbc5dd153b8c3ebcb8163c765ce99a34

See more details on using hashes here.

File details

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

File metadata

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

File hashes

Hashes for typos-1.14.1-py3-none-win32.whl
Algorithm Hash digest
SHA256 55556ccb158d80bc8627ea4207027644b3a6ce850b6d8dc65f05418c8527b5be
MD5 eadc8e511b671cc98ecd77b8359d3611
BLAKE2b-256 8616f137b66b5da1dcc9eec71e13fad21d752b04047fa9f115a6b07ec828f7df

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for typos-1.14.1-py3-none-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 963f9ff4b64e00bd6ad9f87aa0e1acd6c37cebfd63881c263c2f9f78f84e554d
MD5 86a64596a7736c8796db20e7303dce23
BLAKE2b-256 3a10f3e2b081b82b303eefacb98ee29011c53bfdba51cea24581d3ef0db1c254

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for typos-1.14.1-py3-none-manylinux_2_17_i686.manylinux2014_i686.whl
Algorithm Hash digest
SHA256 e28e45127f15022b3421c22dc3d401bd5568020b94b8d01e1b8b1c9d31ce3723
MD5 6801aa25651385eeda25ceb7268f6398
BLAKE2b-256 827622d26b9544bff681cef9e3cd12656b95bcae988306ce865774b930bff854

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for typos-1.14.1-py3-none-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 8d2253f6f52343b8ac9fb2dc65afd8da2286c16cd19ec86d33b6bbe323c28c5b
MD5 ab04be842fe31aefd82a4853ac0f4f54
BLAKE2b-256 79542e9cc689e507b039c7646c792e958f44deb4903bded4adc1cecabbc4b2d6

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for typos-1.14.1-py3-none-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 8775bcc26337f294d980edb69c05918806da2ec456bdc1e0c53a05ccae5b44a7
MD5 9e67bad270f4c69f5fdec157b399e1e3
BLAKE2b-256 82217db70c3f694ece6c1fc0595180aa85033e8da521746e81c9bea9ba86c1e6

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for typos-1.14.1-py3-none-macosx_10_7_x86_64.whl
Algorithm Hash digest
SHA256 40c367bb4258badcde3a5c42fb5b4c38dd52f4752344f6f67542137bf14a162a
MD5 f3f501e7d9f3d3585dc06cdf7959de5f
BLAKE2b-256 8762f8cf756f1232ceb6b8eef015addbaf832fd188c9dc1c6520ccea58005040

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