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

Uploaded Python 3Windows x86-64

typos-1.15.5-py3-none-win32.whl (2.7 MB view details)

Uploaded Python 3Windows x86

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

Uploaded Python 3musllinux: musl 1.2+ x86-64

typos-1.15.5-py3-none-musllinux_1_2_aarch64.whl (6.1 MB view details)

Uploaded Python 3musllinux: musl 1.2+ ARM64

typos-1.15.5-py3-none-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (6.3 MB view details)

Uploaded Python 3manylinux: glibc 2.17+ x86-64

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

Uploaded Python 3manylinux: glibc 2.17+ i686

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

Uploaded Python 3manylinux: glibc 2.17+ ARM64

typos-1.15.5-py3-none-macosx_11_0_arm64.whl (4.4 MB view details)

Uploaded Python 3macOS 11.0+ ARM64

typos-1.15.5-py3-none-macosx_10_7_x86_64.whl (4.5 MB view details)

Uploaded Python 3macOS 10.7+ x86-64

File details

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

File metadata

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

File hashes

Hashes for typos-1.15.5.tar.gz
Algorithm Hash digest
SHA256 e1c139ac8642a2f142bd579544025838b95f1e57fdf13113092f0eedd078aa23
MD5 49b4b79f37b3e1c66bdf18d2bf7a8e9d
BLAKE2b-256 915a6f52831f8a504da439da7ef189f41b3fe1905eecc598ef72a13157b3d8fb

See more details on using hashes here.

File details

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

File metadata

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

File hashes

Hashes for typos-1.15.5-py3-none-win_amd64.whl
Algorithm Hash digest
SHA256 41c4b2b0ea3df50bd3629b4e3da13909a54c42a8891ddf86d759c1137d339025
MD5 2cee31e37a9790e024e587cc8a4a2513
BLAKE2b-256 b87d7a6c70a3d2786ebdc77db6546e34fc07bb056f72716fd8535c0a76958a52

See more details on using hashes here.

File details

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

File metadata

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

File hashes

Hashes for typos-1.15.5-py3-none-win32.whl
Algorithm Hash digest
SHA256 9abcfb7cdc637f5d92ca7cc92dbdc9a6084d2e136574840482cf16287832d835
MD5 54361b27d6797939be4aea4c1c31e875
BLAKE2b-256 c6ddd3d5f6a8d8aedfa1104c48ca3eaff61c984d44c8662aa874d152c87649a1

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for typos-1.15.5-py3-none-musllinux_1_2_x86_64.whl
Algorithm Hash digest
SHA256 ac8d77de0aa457da8a4ae142c5aa8850a57f0e846d3a2a97ad482a1f458f6573
MD5 4543fe7b717e869b79afceb5b2b03951
BLAKE2b-256 f39717b10040293c2470591db18d59859b724bfe1dc89999701e13df24c02733

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for typos-1.15.5-py3-none-musllinux_1_2_aarch64.whl
Algorithm Hash digest
SHA256 52a5b78159029708945aadb86baa6a14be6c2c332d128d97a2ded68ee1d77533
MD5 86519f662073678704aaf3375aa3ddf8
BLAKE2b-256 0b88a73fe7107b77389b1b91e138d1ee42d31f5bb37e0e5bd24a8ad53b263016

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for typos-1.15.5-py3-none-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 45a9f978b0728d405b15fdcbe19421248ac4cf8a39ea7b1db53d4b722083b29e
MD5 b9c3bc192e5799911002f8b81a53735e
BLAKE2b-256 d3bbc2b50b82445168581055ed08efddf8ce8b2924e99d1330f9006a24f87d2e

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for typos-1.15.5-py3-none-manylinux_2_17_i686.manylinux2014_i686.whl
Algorithm Hash digest
SHA256 da5e718c646ca50b7bda506c5bd1b2f158ae570e2b1ed1f8061ae09ba1e1fb99
MD5 352fd855b9dc337a070072d9c4348a98
BLAKE2b-256 0db4cdf1a09286fcb0152e4e0d559a5c59369b27464d5bfc693e395a0a689904

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for typos-1.15.5-py3-none-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 be1bfbd8784106823c672ea7e08fe464d1f3018cb57ccda5ca6926e48a997cfc
MD5 317bb9e3397c556a2723614122314e90
BLAKE2b-256 7c6c7f93f58b26d39f2ff1fbf37b29d18eb4b434520a5cc67b5f6f4be9706dad

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for typos-1.15.5-py3-none-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 3af1797766a1e323a10cc176deae238b7de3c5870d3586cd5316e9779923e6f0
MD5 baea8dda9164b0b061ee120ab79f3fd6
BLAKE2b-256 5dc9e4162bc0111ba144024fa6e64890b77fe74d80459b502efce0a5cddbcde4

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for typos-1.15.5-py3-none-macosx_10_7_x86_64.whl
Algorithm Hash digest
SHA256 5732e1aa87234c97ea7427e98b5fd8abc29b8918a762c30a0059cc1724de5ef2
MD5 cd06f582da8322b587d91095eb39695a
BLAKE2b-256 c78737c5b6ba8c9e56c61b074ea395c55a1e4c992cd2e7284b27a7156c408dfb

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