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

Uploaded Python 3Windows x86-64

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

Uploaded Python 3Windows x86

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

Uploaded Python 3musllinux: musl 1.2+ x86-64

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

Uploaded Python 3musllinux: musl 1.2+ ARM64

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

Uploaded Python 3manylinux: glibc 2.17+ i686

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

Uploaded Python 3manylinux: glibc 2.17+ ARM64

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

Uploaded Python 3macOS 11.0+ ARM64

typos-1.15.0-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.0.tar.gz.

File metadata

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

File hashes

Hashes for typos-1.15.0.tar.gz
Algorithm Hash digest
SHA256 29d53486be15067796d9e9e0b513193a1370651bd75e52b7c524b28a8c8d578b
MD5 24c274b32a57af64c766c55ff77a7d64
BLAKE2b-256 2bfbb3a921770110ba09c7ffa2892bd6b460313b68ea1560e6d77de0bf1c7125

See more details on using hashes here.

File details

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

File metadata

  • Download URL: typos-1.15.0-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.0.1

File hashes

Hashes for typos-1.15.0-py3-none-win_amd64.whl
Algorithm Hash digest
SHA256 9d205db36eeaef2c2f74d098da52d74a92907e97a7ddba8a0563dea5fafcbba8
MD5 80b0ff818225b7baf02770fcf33868fa
BLAKE2b-256 cfcc767b25e5c08bfb7c3ff1c148ea2a7e4df2bf17482dbe403de74fd06e79fc

See more details on using hashes here.

File details

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

File metadata

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

File hashes

Hashes for typos-1.15.0-py3-none-win32.whl
Algorithm Hash digest
SHA256 c23940ac42d38d3ceeced0b4664ec70821df61252efe490979069873d25f0637
MD5 4aebfb265f2d98ee42aa786cc9dbd5c0
BLAKE2b-256 139f0ddd07612d2282e123b9b0ecb5a05b6b2a6844905af9aaabdef67a632479

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for typos-1.15.0-py3-none-musllinux_1_2_x86_64.whl
Algorithm Hash digest
SHA256 350c2533bf6eed51c788cd68b248cc9a542f4f1c2f6e2eae78f6d13cf825d5fd
MD5 f9bb13119f23e9f6ff1da73f247aadfb
BLAKE2b-256 3ab0c1e167cbf6a8568522fe594c2e141994a2d3eb6ea227bd29ded35baccf24

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for typos-1.15.0-py3-none-musllinux_1_2_aarch64.whl
Algorithm Hash digest
SHA256 8e0b20b2feb8170630ef3d45ac4e6d13754bfcf4312385e708ab559b3221a150
MD5 6248263285efcb439ae29c07e0f49ad5
BLAKE2b-256 4ad4ac6f1faa09b469b9b6f036bea11f82f727ce32fdaa371d7da76ecb2e23ea

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for typos-1.15.0-py3-none-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 f8eabff104661a16059eb7ceb244cbbeeedba0fbaf1a56cf5c9647fb488c503a
MD5 0444b61d979fa2526b49c86bc491e54d
BLAKE2b-256 996290758f8a9cae79a6985f91d138d04a95ae28c13dcb3d0f6e92dee42cc663

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for typos-1.15.0-py3-none-manylinux_2_17_i686.manylinux2014_i686.whl
Algorithm Hash digest
SHA256 277bfa9cc60e7ccd755131292f2411657bbf63af8ab84fada28006b0822931b4
MD5 7792b4c1f12e435dd09599b1e5575e67
BLAKE2b-256 bbab32bf30034deddd1a65037bf533a0e2eb42513f6842520316dac69cfae29e

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for typos-1.15.0-py3-none-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 7fcc6e705ddb092f4cbcc6bc05acd34ff6e3a8a9fc61ecca0f60c46325b39b85
MD5 36f3ed3615b498ad23b8edfaffe933e7
BLAKE2b-256 0bd8c3c4c520dc56bebb97443bcac5aefb7065104ce7e7541506a02bbb614662

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for typos-1.15.0-py3-none-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 24e07f9d2789a42570c1038d662ca5322eec1eb915ad418f29a801e02bc75eab
MD5 27d30799e04c1e0c00d734b7aa769590
BLAKE2b-256 778efb67c95d086f608aa69dd0c9a3279a936d901f3f265ade1ec3341d08f76c

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for typos-1.15.0-py3-none-macosx_10_7_x86_64.whl
Algorithm Hash digest
SHA256 be1563fd06e1630d1458ef423b28b5b6a2d63f32fba5be08fc0f320e1ac8b053
MD5 82262d43ab24844a3aba9e29cfcac67b
BLAKE2b-256 08135718df09e276561cedee61010d7f2706f3660ebeb40310ad9f3810ddcf38

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