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?

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 --identifers 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.18.2.tar.gz (1.7 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.18.2-py3-none-win_amd64.whl (3.0 MB view details)

Uploaded Python 3Windows x86-64

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

Uploaded Python 3Windows x86

typos-1.18.2-py3-none-musllinux_1_2_x86_64.whl (6.3 MB view details)

Uploaded Python 3musllinux: musl 1.2+ x86-64

typos-1.18.2-py3-none-musllinux_1_2_aarch64.whl (6.0 MB view details)

Uploaded Python 3musllinux: musl 1.2+ ARM64

typos-1.18.2-py3-none-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (6.2 MB view details)

Uploaded Python 3manylinux: glibc 2.17+ x86-64

typos-1.18.2-py3-none-manylinux_2_17_i686.manylinux2014_i686.whl (5.3 MB view details)

Uploaded Python 3manylinux: glibc 2.17+ i686

typos-1.18.2-py3-none-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (7.3 MB view details)

Uploaded Python 3manylinux: glibc 2.17+ ARM64

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

Uploaded Python 3macOS 11.0+ ARM64

typos-1.18.2-py3-none-macosx_10_12_x86_64.whl (4.6 MB view details)

Uploaded Python 3macOS 10.12+ x86-64

File details

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

File metadata

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

File hashes

Hashes for typos-1.18.2.tar.gz
Algorithm Hash digest
SHA256 5ac8fd37f892bb74de5acb44bde3338cbb2eca44b406f24cdecc76a81edd1676
MD5 270f07186e2ca77bf3824582b67db41e
BLAKE2b-256 d48bc6e2cef7f292e4eea672ad20dcf0cd7d0abd5d0538bebdc9b07dd613a0b2

See more details on using hashes here.

File details

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

File metadata

  • Download URL: typos-1.18.2-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.4.0

File hashes

Hashes for typos-1.18.2-py3-none-win_amd64.whl
Algorithm Hash digest
SHA256 28a583aeb65031f74f0e6d139956930161e3c4b73510478898b251c808d82706
MD5 ca02eb5e0bd7bbb88c9715c7f3d230c3
BLAKE2b-256 b7f08f817c5eca5b35ac062fccbd4792a3cf572e05fa19ed8fa5d6ccb69775de

See more details on using hashes here.

File details

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

File metadata

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

File hashes

Hashes for typos-1.18.2-py3-none-win32.whl
Algorithm Hash digest
SHA256 b3efa4a9fe7e434df751355cb18bcee00dbacf75eb4608d99ceefe2ef9d0c5f4
MD5 92ffd589cfd8da60147119cb1208cc96
BLAKE2b-256 8fef56ec9a50335aa06171a16d6c00b8b17e2d235e9ca7d074abaf2606d02944

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for typos-1.18.2-py3-none-musllinux_1_2_x86_64.whl
Algorithm Hash digest
SHA256 32f42c035161810b3e279f23715408b5421e2fadc491fe32e5f4c7ee7ea8881a
MD5 fa0282e036738cd08737d2930268b929
BLAKE2b-256 b53528be0702a08919c67fc8c4bd6c43ca8ea9783e683cbb8f7978d27c3a17ff

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for typos-1.18.2-py3-none-musllinux_1_2_aarch64.whl
Algorithm Hash digest
SHA256 75e2097be128e73f465741e337b2a3fae7a8b5cddd7f30abaec7f9f92c9e8863
MD5 2af081e90507445c88cb04662d0a7b29
BLAKE2b-256 af107b45b08040454383113f30dd3ce3acccb6c1c3bd3325f386651d4e7f840b

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for typos-1.18.2-py3-none-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 8241c6a5f6a77937badf23fe318d3dcdf36c46c97f1cf8b73a4158c7e3414d9a
MD5 ed043181e57d58e56abe15d995629cc2
BLAKE2b-256 f89707818995cfc0e254461960aa677d04447ad5a041a6abc79e5415e23ed9d6

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for typos-1.18.2-py3-none-manylinux_2_17_i686.manylinux2014_i686.whl
Algorithm Hash digest
SHA256 608d5d30c0fe9d1b2b007fc8924e791cf7be4750dc1ef0cd0a2d41688c849155
MD5 9b36a360ba5eb85732a9089ed0a815ed
BLAKE2b-256 d6af03de92385d1dcdde907a9b1c42278c45b271dd04e484e9aa1cbc61e196d6

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for typos-1.18.2-py3-none-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 190132183a1dce4c3a5990bf383c893bf95871f8feb122fccf9ef6b0dba3a422
MD5 d019db66999a469a74a19d6904dce066
BLAKE2b-256 1c4f27a6afa090712aba27d6cea8cdbf36c19572489fa2c5a0289293cd657c88

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for typos-1.18.2-py3-none-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 e442333b7d09002d4cc34946c120757f7af6ecda55270ce574f552dd8758b1eb
MD5 3590f9e45628a159d7ce814fe6947a78
BLAKE2b-256 03607dc623b3f290a6d4d8d7be7a3171c3ce10beb5b76ada87218f78076b5d00

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for typos-1.18.2-py3-none-macosx_10_12_x86_64.whl
Algorithm Hash digest
SHA256 dbfa8637fcc530b57890a40ced904edba643cf07334e7cc7e34a4ceaeb2fd13a
MD5 634e179a998133cb0040d00f287791d5
BLAKE2b-256 d72bbd9ad29ba2888ee0d563c0158134cde269e5c7b2054c920bf5c3562efcf2

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