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

Uploaded Python 3Windows x86-64

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

Uploaded Python 3Windows x86

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

Uploaded Python 3musllinux: musl 1.2+ x86-64

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

Uploaded Python 3musllinux: musl 1.2+ ARM64

typos-1.24.6-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.6-py3-none-manylinux_2_17_i686.manylinux2014_i686.whl (3.5 MB view details)

Uploaded Python 3manylinux: glibc 2.17+ i686

typos-1.24.6-py3-none-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (4.9 MB view details)

Uploaded Python 3manylinux: glibc 2.17+ ARM64

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

Uploaded Python 3macOS 11.0+ ARM64

typos-1.24.6-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.6.tar.gz.

File metadata

  • Download URL: typos-1.24.6.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.6.tar.gz
Algorithm Hash digest
SHA256 0feda2aab59fc1c32cd1f382ea8676b4ef0921086ab172a43e69e5bb19206993
MD5 cbae910f679ee18b34f5a7b1673d545d
BLAKE2b-256 92440d3f5a153919bc757573fe89200ae77609a440b1b774d04e5f816839ee58

See more details on using hashes here.

File details

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

File metadata

  • Download URL: typos-1.24.6-py3-none-win_amd64.whl
  • Upload date:
  • Size: 2.6 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.6-py3-none-win_amd64.whl
Algorithm Hash digest
SHA256 12972e7a8be14fe5e7f0392de0b228a0098748959d1fecc35c4e8eab3efc04c0
MD5 1e44bcd418fb8ce2e50ea36a5b9ae04a
BLAKE2b-256 93ec2842da6226fe6c3c5a030364f65d99901c06507f6575c5f8250bc3602d9f

See more details on using hashes here.

File details

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

File metadata

  • Download URL: typos-1.24.6-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.6-py3-none-win32.whl
Algorithm Hash digest
SHA256 cd725db3823c319f7e97b4e8e9fa4af143568b1c7d834f66c584bf86b9691f94
MD5 72f6dc309a23c276e61e63be8ee4fce7
BLAKE2b-256 71b3fafc840ea619798a7f98765c76eeb13e9227175509172f7a730cbd633396

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for typos-1.24.6-py3-none-musllinux_1_2_x86_64.whl
Algorithm Hash digest
SHA256 7e27c307c26549a7986f2701f161358df29543e818bf9d6d81f0a81ca5ddeff5
MD5 e1e9f4bacb033362435101e7ae20cb54
BLAKE2b-256 1f02336eb3315e1d53a780d98511b465cd801be9151294bcbb50a603d503b5de

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for typos-1.24.6-py3-none-musllinux_1_2_aarch64.whl
Algorithm Hash digest
SHA256 7291555c82e81e305ab3e10cb04d0f7d49ccecc1ced322c60f4619f6a14c7225
MD5 629dcecff029ce2ff48af9223bc3e151
BLAKE2b-256 8609e0cf7945287e4d7a61403237a1df2def419734a6a8e41f06829187f96ee2

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for typos-1.24.6-py3-none-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 e2abbe9dc208f6da9fddbf9bb281a3944d66188df9b3d43ad6f2f99721713446
MD5 4e98ffa2a85f4a75e439302d551cff5f
BLAKE2b-256 3b6fd8ecddc82501b01a0e956173060c3b216bc9a7ee4c66d5b5c07dd02305c6

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for typos-1.24.6-py3-none-manylinux_2_17_i686.manylinux2014_i686.whl
Algorithm Hash digest
SHA256 b8eb05826d6ff1f8747e1c7d9991a10e13b644b2eb7e2855cc79a37ebb1104f1
MD5 8b798df2d204848b311cfb725cc8615b
BLAKE2b-256 38563aebbf2f950a15343396cbfc4773d4de5dc632867210051516cb4faef83f

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for typos-1.24.6-py3-none-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 dfbd7c40af229d680c2b9bc90e846eea70626bde9608f77a57c4e72145a5aa5f
MD5 f8bfd6d7c0b3177e9fc7469495653a47
BLAKE2b-256 b1a9d63c5be9eb7a0105ae6b1257c6bae98595d52198b8c53359f6b93618d9f8

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for typos-1.24.6-py3-none-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 49fc10b7d28a6a016678c92a5b3d091ea46a2a7e09d5d1122045e8509378f785
MD5 a9c5a9de37f6721cafeb9cfafb33d61a
BLAKE2b-256 b8d0c4f711a402c938c87ea3ee2bc173bb6ecb1a9869b662245eb97c56571f18

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for typos-1.24.6-py3-none-macosx_10_12_x86_64.whl
Algorithm Hash digest
SHA256 be576cd0afcbf72bd0fa4129d457b146627c837db189eae7ee83b9fc311dacef
MD5 598fb9cca537db351cff98fc1a11e549
BLAKE2b-256 ad6b75bf4f3de20c5edc17919b55b592dffade154ccee7c65512b2f506514082

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