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

Uploaded Python 3Windows x86-64

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

Uploaded Python 3Windows x86

typos-1.16.7-py3-none-musllinux_1_2_x86_64.whl (6.4 MB view details)

Uploaded Python 3musllinux: musl 1.2+ x86-64

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

Uploaded Python 3musllinux: musl 1.2+ ARM64

typos-1.16.7-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.16.7-py3-none-manylinux_2_17_i686.manylinux2014_i686.whl (5.3 MB view details)

Uploaded Python 3manylinux: glibc 2.17+ i686

typos-1.16.7-py3-none-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (7.4 MB view details)

Uploaded Python 3manylinux: glibc 2.17+ ARM64

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

Uploaded Python 3macOS 11.0+ ARM64

typos-1.16.7-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.16.7.tar.gz.

File metadata

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

File hashes

Hashes for typos-1.16.7.tar.gz
Algorithm Hash digest
SHA256 1b35168849f770ffade669231b3bfa61ccbb3f66b8027f415babc814898aac26
MD5 a3fa5930b7f606c0e98f7b1613f304ba
BLAKE2b-256 7db940fe1bf03765c00a7351115893686f33794963e3f15320de83f383408f24

See more details on using hashes here.

File details

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

File metadata

  • Download URL: typos-1.16.7-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.2.3

File hashes

Hashes for typos-1.16.7-py3-none-win_amd64.whl
Algorithm Hash digest
SHA256 7cc0302a0cdef7bb58889780fcf158655615a177a7117e398ea396377285a3bc
MD5 5779d795325e5c8904f06a26d24c41ae
BLAKE2b-256 ad6c1e4aa5bf435d10e9a53a0e100c6f17caad9713eeeffce8ca66a62bbed6d3

See more details on using hashes here.

File details

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

File metadata

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

File hashes

Hashes for typos-1.16.7-py3-none-win32.whl
Algorithm Hash digest
SHA256 cb292a0dd757579396472915574b8a965eb03156eb2a4d899aa4af464ab5c0e5
MD5 30a6b2b925b5f2ddb6aafa22d595cc24
BLAKE2b-256 40b791c9be51e2baf750ca03dfb4afcc7c119314e1283677bc43d639e0b473ea

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for typos-1.16.7-py3-none-musllinux_1_2_x86_64.whl
Algorithm Hash digest
SHA256 c466828c802c9699061231e0a8f3d6c94d80214521b393837bcb8b41a1f96a8c
MD5 d35f0388ef05a1a353fa736da19beed1
BLAKE2b-256 c053b01d1337b4f20f9270c94c8548e6b9fcb973b44ca3c54a9745029c52b1fb

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for typos-1.16.7-py3-none-musllinux_1_2_aarch64.whl
Algorithm Hash digest
SHA256 10541246d3114a9e332b25ed5d7d5b2e05bc8d483309ab6922ac4db8b793b9cc
MD5 47eadf45294be4bd529799a3022d5574
BLAKE2b-256 4ca77080b66a948c9d399f1c59f19fb679b14d05f52fbb9732eb20cafcf73c3e

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for typos-1.16.7-py3-none-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 99419e8ba63fc0671711ef42cfeab5f702a814872732d4fc6ca4475f3eef8888
MD5 520bddc2def6206a69b3f3c61e0f0b0d
BLAKE2b-256 6a1d7c0f1efbafaf1141c145dd60fa0255e8921644109624fe5d18eca7d04e20

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for typos-1.16.7-py3-none-manylinux_2_17_i686.manylinux2014_i686.whl
Algorithm Hash digest
SHA256 78d22ef59eb028a7f52adf58383824d301d5ae20e69f1c09cb7e9d72fe0375dd
MD5 0e9a9d5b7f5dfdab5a77e70f353fd633
BLAKE2b-256 8332109a802a3b181960ce2fe673410d7778a4aae479c4866e7b7c2141d6b965

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for typos-1.16.7-py3-none-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 d7ce000441fed269924e10318681fc402ed2226d6e2efae97275ae4f7b9b01d2
MD5 67637ea4d0bec0455e7c01f1f032f021
BLAKE2b-256 f4fdf01b0fbb6726bafa72c598a7fc4f120da77ffa258c809e16cb4446f19ee0

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for typos-1.16.7-py3-none-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 06100d0fb198124936bbd7f452609e9aea464948d35fdda560db968c99c0d6f6
MD5 0b80f96ef1271181c5d233eed274e417
BLAKE2b-256 e126b5e5101ea4e7963ed9c17afb3b33fb35c874e466f4d7c36fb31a8e19b567

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for typos-1.16.7-py3-none-macosx_10_7_x86_64.whl
Algorithm Hash digest
SHA256 c4fe15cfcea1945347d76a8ea5e67febee71ee9a49e31653c842ecfe50faec71
MD5 e1bbdf160c617032e9883583746b2fff
BLAKE2b-256 5f93524d2a795f47e92c2caac328c163e4274128e5afad80e2e70939ec6eed79

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