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

Uploaded Python 3Windows x86-64

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

Uploaded Python 3Windows x86

typos-1.16.23-py3-none-musllinux_1_2_x86_64.whl (6.5 MB view details)

Uploaded Python 3musllinux: musl 1.2+ x86-64

typos-1.16.23-py3-none-musllinux_1_2_aarch64.whl (6.2 MB view details)

Uploaded Python 3musllinux: musl 1.2+ ARM64

typos-1.16.23-py3-none-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (6.4 MB view details)

Uploaded Python 3manylinux: glibc 2.17+ x86-64

typos-1.16.23-py3-none-manylinux_2_17_i686.manylinux2014_i686.whl (5.4 MB view details)

Uploaded Python 3manylinux: glibc 2.17+ i686

typos-1.16.23-py3-none-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (7.5 MB view details)

Uploaded Python 3manylinux: glibc 2.17+ ARM64

typos-1.16.23-py3-none-macosx_11_0_arm64.whl (4.7 MB view details)

Uploaded Python 3macOS 11.0+ ARM64

typos-1.16.23-py3-none-macosx_10_7_x86_64.whl (4.7 MB view details)

Uploaded Python 3macOS 10.7+ x86-64

File details

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

File metadata

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

File hashes

Hashes for typos-1.16.23.tar.gz
Algorithm Hash digest
SHA256 e6ea2f7f8aba7c82db911226f8c077dad5defdd917e147ed82f0bfca39317e8c
MD5 922eece702ecfe5cf37ac175e60ddcc8
BLAKE2b-256 78d5b42a6740102ce72b8530e19f96933332cef07892dd463b6d9586731b0c55

See more details on using hashes here.

File details

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

File metadata

  • Download URL: typos-1.16.23-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.3.1

File hashes

Hashes for typos-1.16.23-py3-none-win_amd64.whl
Algorithm Hash digest
SHA256 c0905627eaf4fc0f66577ec57ef6829d3b1a531b389837c7e86d2bbc5dc2eeac
MD5 5b83827b83cf28833a54b4bf8a17a10c
BLAKE2b-256 8f30a23cf80efbe63234e2d72f423630531b1f67455cd88c1966d0016e1cb10d

See more details on using hashes here.

File details

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

File metadata

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

File hashes

Hashes for typos-1.16.23-py3-none-win32.whl
Algorithm Hash digest
SHA256 8647c6272a2e9f6b372f3195ca7a9387689576c7700215ec8dcfe572e5a6df5c
MD5 015a277064f80472f7c5fbcf06f7375d
BLAKE2b-256 a9085e7392bafc864cd207cdb068a4d20fecdc5ca30a66c2d3ea2f12b79db304

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for typos-1.16.23-py3-none-musllinux_1_2_x86_64.whl
Algorithm Hash digest
SHA256 83a8ec4d48ef4fd1a783805a4832f79cf9d4d3bdf0f5a4ccb821323ef189bd62
MD5 f5652d5d168cab1a6a366add41b9760b
BLAKE2b-256 ce9301f524ef12e520168cfbb0ab53ee914b25a486d54fe16fa74ab143acc943

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for typos-1.16.23-py3-none-musllinux_1_2_aarch64.whl
Algorithm Hash digest
SHA256 34aa9ccfd5cc881324b26584f253b08d418fc87057dc04fd409720d0b401e929
MD5 9da1addd120b3d0b5fe55030e8ef1318
BLAKE2b-256 05ed129b5e14bc6230d0945f5262beee908468a716e39fe2341159b5238ff55d

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for typos-1.16.23-py3-none-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 bb4753028a8f6e08f762afd861797de0146e6a0f960d37e53f4165c46c8397a4
MD5 1eca853841d376fc7d52e8cae15d0717
BLAKE2b-256 93331955c1331ac033192d4b8fc98a69a6bacc938ba7e35805246d8cfe4fd0b8

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for typos-1.16.23-py3-none-manylinux_2_17_i686.manylinux2014_i686.whl
Algorithm Hash digest
SHA256 12b70bd3a6a2600edd53c40f002b54a290cc12623ac23978dfd0f1496ceb7419
MD5 49a16eca9d3807f43deef198998efcc9
BLAKE2b-256 236af4d207d65f234904165e746d17e0e648796379ace1b24230e0b6a248906c

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for typos-1.16.23-py3-none-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 51b771b990af209c38e1d83dc7715cc60b5234186a7ac050d657b78716a0232b
MD5 9d37b6e7387bd0aec424887c20dc3772
BLAKE2b-256 9bd2580e6796880f753bd053b09bd380872d757b6b8eb2cdee4930831733d08e

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for typos-1.16.23-py3-none-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 8f498453bf582246b8c7d13af1a2f24ba1dffd0dba3674d0e29edcd7b73d3077
MD5 7591ddb257a5ee86ebec382ef64aa4c0
BLAKE2b-256 c9c05556a26e714012beef7ca00a0af2c2086dff52a9bf6821aee9ca383afa9a

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for typos-1.16.23-py3-none-macosx_10_7_x86_64.whl
Algorithm Hash digest
SHA256 aabfca30e49dde82cd8249f2770f9ff461a4ae9510dae0eccd3d1d61c9939e7b
MD5 70e73008dfc8e03cf95ed14d8bd4de4b
BLAKE2b-256 75b32a249a7c7144d51f949f3fc8d2413c9aafd14e63ea80e10d85cac147dc1a

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