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

Uploaded Python 3Windows x86-64

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

Uploaded Python 3Windows x86

typos-1.24.5-py3-none-musllinux_1_2_x86_64.whl (4.2 MB view details)

Uploaded Python 3musllinux: musl 1.2+ x86-64

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

Uploaded Python 3musllinux: musl 1.2+ ARM64

typos-1.24.5-py3-none-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (4.2 MB view details)

Uploaded Python 3manylinux: glibc 2.17+ x86-64

typos-1.24.5-py3-none-manylinux_2_17_i686.manylinux2014_i686.whl (3.5 MB view details)

Uploaded Python 3manylinux: glibc 2.17+ i686

typos-1.24.5-py3-none-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (4.8 MB view details)

Uploaded Python 3manylinux: glibc 2.17+ ARM64

typos-1.24.5-py3-none-macosx_11_0_arm64.whl (3.4 MB view details)

Uploaded Python 3macOS 11.0+ ARM64

typos-1.24.5-py3-none-macosx_10_12_x86_64.whl (3.5 MB view details)

Uploaded Python 3macOS 10.12+ x86-64

File details

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

File metadata

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

File hashes

Hashes for typos-1.24.5.tar.gz
Algorithm Hash digest
SHA256 b31af4d73fd35c6cda7530c5f9d7ca23ecfa11e97d4709783496353cef7e7a73
MD5 7e13c1c68214f781c393357ca7b7fc15
BLAKE2b-256 0033ebce72a854a36bcdb8693800818495a59040fb7f5f27e743f4dcf3007949

See more details on using hashes here.

File details

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

File metadata

  • Download URL: typos-1.24.5-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/1.7.1

File hashes

Hashes for typos-1.24.5-py3-none-win_amd64.whl
Algorithm Hash digest
SHA256 47c237a0bbcd8ab432a562020c386abe45f8ea71218b74d800d799d65b39d08b
MD5 5427c508cb5ee42e79948084506095e8
BLAKE2b-256 88539b26e8d51f8a493c6eab7bde1c83eae071f4b22f5ff6eab6d74cae1e3442

See more details on using hashes here.

File details

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

File metadata

  • Download URL: typos-1.24.5-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.1

File hashes

Hashes for typos-1.24.5-py3-none-win32.whl
Algorithm Hash digest
SHA256 e6a7b77c13e49a5791d3be537eede2e8f4496e662aa7501260344edd5ba7df86
MD5 ef619d570c3ef4ece3c79cfc2bb13b7e
BLAKE2b-256 5f6163b052d6867a233adb58b1d75e56ebcf812ecfc453edf0646fdd3cbc9ea6

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for typos-1.24.5-py3-none-musllinux_1_2_x86_64.whl
Algorithm Hash digest
SHA256 b226d2f2960e6a5430a0af30b896e2e067ffa9fe98ea4196c0f514ad97219c47
MD5 c8deee8a56f57a753c35db108c0757b0
BLAKE2b-256 63150c1a45eed93bc515943f79ad8932bdea133b810385219325d1f1e9622c86

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for typos-1.24.5-py3-none-musllinux_1_2_aarch64.whl
Algorithm Hash digest
SHA256 b3e2f44f7f39272ae0cce3f3b89157218db82f5214354d76d3a60f1af0bd0602
MD5 987145c37c71ef6a09a341a3b615ae21
BLAKE2b-256 c7fa4113ff4f311aebc5b3203aef9ba042d57c7865b09d9d4a2a5d5e12f5d7e5

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for typos-1.24.5-py3-none-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 1433c987eb2dec6ce627e381870aa36f44cb98696ca4f9ff194abb87bc2075d3
MD5 94c95515051e3ef8cb5f1bfdfc33b1f4
BLAKE2b-256 34fa0145ad29a38782dd73e519c83cacc0afb4f8c09452b51d70a9771526c703

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for typos-1.24.5-py3-none-manylinux_2_17_i686.manylinux2014_i686.whl
Algorithm Hash digest
SHA256 8940a50ad420dc7924e0db520c88cedce2c6cc88f206c621755e5a966c0ad645
MD5 b787bd30025fd03c29a6b35191501aae
BLAKE2b-256 f8bd8ce93dfb721e5ed4ec9931425670e57daebb72bb19b55ada2e19e2048104

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for typos-1.24.5-py3-none-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 00e1f569ddc8ed80255114cbbbdcb9db278ae738f4ee435ba60803b2c8e7d519
MD5 4c6d78187d0b6b305bf25314134fd7c2
BLAKE2b-256 4ab45f38cb95cdff69c5c29ba88555c6aa8ec5b75185a2d52daea6e5de12e3f7

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for typos-1.24.5-py3-none-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 9a4634eda1082fbe9e7b3fc947870b36b50a964f6b89861ccf19bb9ebf26ddd9
MD5 b3262db38d5b1ea2eb39eae847be64bb
BLAKE2b-256 635aa95034fc546a82a2592f6b017c763e832e5c3731db42b3530ddf645625d6

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for typos-1.24.5-py3-none-macosx_10_12_x86_64.whl
Algorithm Hash digest
SHA256 95a75c76ecd4aa32b8a18b5aed9f20e4223276851ffa9d77d552533ed3e23198
MD5 faf2bd1176be7a4a9119d6971836b07d
BLAKE2b-256 d69e475a6484757c51f1d9d43eae95f117d8e981a9d86e37b14a764657ec7777

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