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

Uploaded Python 3Windows x86-64

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

Uploaded Python 3Windows x86

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

Uploaded Python 3musllinux: musl 1.2+ x86-64

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

Uploaded Python 3musllinux: musl 1.2+ ARM64

typos-1.22.5-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.22.5-py3-none-manylinux_2_17_i686.manylinux2014_i686.whl (5.2 MB view details)

Uploaded Python 3manylinux: glibc 2.17+ i686

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

Uploaded Python 3manylinux: glibc 2.17+ ARM64

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

Uploaded Python 3macOS 11.0+ ARM64

typos-1.22.5-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.22.5.tar.gz.

File metadata

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

File hashes

Hashes for typos-1.22.5.tar.gz
Algorithm Hash digest
SHA256 8e16d6590fdc967fe9a79add657219275bd2079752402b168962185d8ea3a498
MD5 06205a1a590fcbacb34f777906eaa9f2
BLAKE2b-256 b3179978a21db257cdae27f521a828d32f9056300232576c905ad3d05ee6abcf

See more details on using hashes here.

File details

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

File metadata

  • Download URL: typos-1.22.5-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.6.0

File hashes

Hashes for typos-1.22.5-py3-none-win_amd64.whl
Algorithm Hash digest
SHA256 33a10bbc7692283e1d0d037db5cddddaf6ef64445fb3ff9566f02b993a27e82f
MD5 384e152840fac91a64ac26d2330c11ef
BLAKE2b-256 265ddd2e97ec44295e26f4deaa3cbd890bcaed8b7300d606a203eb7f9f3159ff

See more details on using hashes here.

File details

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

File metadata

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

File hashes

Hashes for typos-1.22.5-py3-none-win32.whl
Algorithm Hash digest
SHA256 1a61a5ff8b4c248f8f8523742b5dfd387907a80edca0bfc6c4e33124340accd8
MD5 a228614ec2c32bc397e5630d2eb60223
BLAKE2b-256 2cef9c0268a4a2ad60ddb2a864f9fbfcf1a53a35859a35ef75c2b01fc6d57dec

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for typos-1.22.5-py3-none-musllinux_1_2_x86_64.whl
Algorithm Hash digest
SHA256 7445c53594e9adf14fb8d6a185cfedec58a23e2063b0e4121117667062f5f4ed
MD5 1e7c78c568c99a92fa0ca25bd6d22304
BLAKE2b-256 a1dd2d94254af8caae947c1edc1d14f5d94301fa33171b9f7f5fac922f3181bc

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for typos-1.22.5-py3-none-musllinux_1_2_aarch64.whl
Algorithm Hash digest
SHA256 d640be1ffcb0008f07940accf1e56b6180762357b06684f21981d2d6d45bd13c
MD5 bae3023c6dd8932228cc623ebac06881
BLAKE2b-256 b2cf42c9e3fc98b47d23926b3ba14b01a4cf9532d4b50f02d939b2f1eefa8beb

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for typos-1.22.5-py3-none-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 a09628be0965407fb363e68a898845ca1a8f775194c5d6b5bd308f20d0d8d46d
MD5 fb18fe353f9a2c8da160a7196ed2d2e7
BLAKE2b-256 549f2994db7f43dbaf41a4417ba28fda379fefd077fdb241fb5b81f43af7d812

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for typos-1.22.5-py3-none-manylinux_2_17_i686.manylinux2014_i686.whl
Algorithm Hash digest
SHA256 b0e5a668544dd5d8e11547e211c950c4909b09a6ed9c10ba27f3f2f20f268d40
MD5 de5249d203311b5ddfa1afbc774b6d4d
BLAKE2b-256 72c26a8e0ef6a0cfbf1daad32625b5b3e5fa5988ad24b5961099905ad9353f0c

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for typos-1.22.5-py3-none-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 ee34658319f35f80877185ad00dfea7d4f6f162b5a0935788060e469ef1e1398
MD5 6b08c04dcc01f0fd54a8d36f376204df
BLAKE2b-256 15da16852f71ba44f86dd908ce20864813d47c5bc6865fec8b1c9620db6866ee

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for typos-1.22.5-py3-none-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 bff0c2b15bc7aa35b3772907fafc8958231d1ec7e5643d8342124cb3b49b78b4
MD5 bbda88a6c759bc9d3661d8e3db2c935b
BLAKE2b-256 7a267ef1157f7572ff51918efb3a496bc8624e5ee4107667d0ef5a34aaf0cf4e

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for typos-1.22.5-py3-none-macosx_10_12_x86_64.whl
Algorithm Hash digest
SHA256 585b55a07aee0fe37bb3e60dba4906ec8e5d9147c02cb0198d683d20c44bfa5d
MD5 8c4805447125eb9baf5dc110ddeeff26
BLAKE2b-256 f11dd8753741078d69003c12834a30df4c9cf145f0fc90f6209f2cc70b0e3d7a

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