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

Or use Pacman to install:

sudo pacman -S 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?

Does the file show up in typos --files? If not, check your config with typos --dump-config -. The [files] table controls how we walk files. If you are using files.extend-exclude, are you running into #593? If you are using files.ignore-vcs = true, is the file in your .gitignore but git tracks it anyways? Prefer allowing the file explicitly (see #909).

Does the identifier show up in typos --identifiers or the word show up in typos --words? If not, it might be subject to one of typos' heuristics for detecting non-words (like hashes) or unambiguous words (like words after a \ escape).

If it is showing up, likely 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.27.0.tar.gz (1.1 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.27.0-py3-none-win_amd64.whl (2.6 MB view details)

Uploaded Python 3Windows x86-64

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

Uploaded Python 3Windows x86

typos-1.27.0-py3-none-musllinux_1_2_x86_64.whl (4.1 MB view details)

Uploaded Python 3musllinux: musl 1.2+ x86-64

typos-1.27.0-py3-none-musllinux_1_2_aarch64.whl (3.9 MB view details)

Uploaded Python 3musllinux: musl 1.2+ ARM64

typos-1.27.0-py3-none-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (4.1 MB view details)

Uploaded Python 3manylinux: glibc 2.17+ x86-64

typos-1.27.0-py3-none-manylinux_2_17_i686.manylinux2014_i686.whl (3.4 MB view details)

Uploaded Python 3manylinux: glibc 2.17+ i686

typos-1.27.0-py3-none-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (4.3 MB view details)

Uploaded Python 3manylinux: glibc 2.17+ ARM64

typos-1.27.0-py3-none-macosx_11_0_arm64.whl (2.9 MB view details)

Uploaded Python 3macOS 11.0+ ARM64

typos-1.27.0-py3-none-macosx_10_12_x86_64.whl (3.0 MB view details)

Uploaded Python 3macOS 10.12+ x86-64

File details

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

File metadata

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

File hashes

Hashes for typos-1.27.0.tar.gz
Algorithm Hash digest
SHA256 1ace06f2f107a939d3ddd2cc3517250b08d8ae95297c3722f48f39b899f3c1af
MD5 e2a48d1a1c45714a2f1e7e7f452daea1
BLAKE2b-256 7e149339fffca6831ddb5c003cbfa22841aff2f0f21ae78821960b58e8f46564

See more details on using hashes here.

File details

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

File metadata

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

File hashes

Hashes for typos-1.27.0-py3-none-win_amd64.whl
Algorithm Hash digest
SHA256 97f799d8428d2f6f2889655a322e582117c6108df4b7de5fb4902d40e3e60850
MD5 239929e0bab66b4438ab5971bed2d5ca
BLAKE2b-256 de6a56fe95c40b4d966755d49fabb022ac1fadcbff5469e81a51226d51789c72

See more details on using hashes here.

File details

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

File metadata

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

File hashes

Hashes for typos-1.27.0-py3-none-win32.whl
Algorithm Hash digest
SHA256 d93da7e3b1c332378acbaab5b326fbf42b5075860044e11d14f51b310f0e3f03
MD5 322bf80f1fe1dd995bc24bb9f7608b18
BLAKE2b-256 18710b8f06c7a29edfb7a7e58b4752fa3ae6c7de2ffb9471b1224dafed3347b7

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for typos-1.27.0-py3-none-musllinux_1_2_x86_64.whl
Algorithm Hash digest
SHA256 984568803b5d87f63d8e1bb26cc16a17e4d942ca0732e01c36ac4311f0809b0f
MD5 205b3c2882e55f0540d6a32a99c0fd66
BLAKE2b-256 f05fd4ab810a9168d5d0cf0ea4842f3fc3537d325dcfd12ffc417a69552502e0

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for typos-1.27.0-py3-none-musllinux_1_2_aarch64.whl
Algorithm Hash digest
SHA256 07f2ea4f5ef7079c71116f4427074c330c17531b7ee75ca6693f3bd7fbbae4b0
MD5 59d8557291483086a39d73f13121934a
BLAKE2b-256 c24bad5af38a987cf92079dd967864ce9a88d4149eea08514968380fddcbb4c3

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for typos-1.27.0-py3-none-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 64f59c0e9c51d279aafd9fdfc8a392eab4ab56ba0786e3e578755c99592433f4
MD5 84b263263207ff63120b892b207c7886
BLAKE2b-256 0baba258e3c916caf1f5e4945c260cb811b391d66d8f63f183bca4560df90914

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for typos-1.27.0-py3-none-manylinux_2_17_i686.manylinux2014_i686.whl
Algorithm Hash digest
SHA256 4b2480fdab0e6e01270cf3d0840d6356cacfe2822894cdaf5c6dc9e1f0be5a6e
MD5 9c06f07a45ce2f3e3f931d114ace493b
BLAKE2b-256 49acea163be3ee8d33299e9875ac42c38e1a25a5e8975344d77f14b972249f00

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for typos-1.27.0-py3-none-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 98b444ebbe052ec04ef79c351efa8373e5913960ef05c6be910d9c75303f5def
MD5 c53a08e3df1c1f721286cecf3f19ab7b
BLAKE2b-256 208edacd4e4ca5aded54b20ac54eb041997ce815e1cd6abdb2ccc8a1cf360794

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for typos-1.27.0-py3-none-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 410b2b23021bb11be49ba7d49ef76be56d400ee04b0aef8a40185dd1f15de366
MD5 b13f9b12c2aaeebc1d391a46544cedb7
BLAKE2b-256 510497ae0f5f2f48c802acb58383af71d9543e16e4fb614644d33fd9d7a56739

See more details on using hashes here.

File details

Details for the file typos-1.27.0-py3-none-macosx_10_12_x86_64.whl.

File metadata

File hashes

Hashes for typos-1.27.0-py3-none-macosx_10_12_x86_64.whl
Algorithm Hash digest
SHA256 4902c9e03c514d8515387301a6509632f45a88db6d86940ee5aee57945d20eb6
MD5 860ac9b2d85d4f10cc1cb4c02ebfc179
BLAKE2b-256 61a9534ccebf318b3fa6e46ad6cde12219cc424f548daa79aed963c326e25ce6

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