Registry / testing / typos
library1.50.0pypypi✓ verified 23d ago

Typos is a fast and low false-positive source code spell checker written in Rust, provided as a Python package primarily for command-line interface (CLI) usage or integration into CI/CD workflows. It focuses on correcting a curated list of 'known misspellings' to ensure high confidence and minimize false positives. The library maintains a monthly release cadence, primarily updating its internal dictionary and applying minor fixes.

pip install typos
INSTALL
IMPORT
SIG · TYPOS
T
typos
testingpythonv1.50.0
Install
1.9s avg
Import
16ms
Disk
16MB
Pass rate
10/ 10
Env Coverage10 / 10
glibc
3.93.13
musl
3.93.13
Install & Compatibility
Where this runs
tested against v1.50.0 · pip install
no network on importno background threads
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
py 3.103.95 runs
installs and imports cleanly · install 0.0s · import 0.016s · 17.9MB
glibc
py 3.103.95 runs
installs and imports cleanly · install 1.9s · import 0.016s · 18MB
16MB installed
● package 16MB
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

typos_cli
import subprocess # Or directly run 'typos' from shell
from typos import TyposChecker
The `typos` Python package is primarily a wrapper for the Rust-based CLI tool. Most common usage is via the command line or `subprocess` calls, rather than direct Python API imports. The core functionality is not exposed as Python classes/functions in the traditional sense for programmatic interaction beyond subprocess calls.

This quickstart demonstrates how to use `typos` as a command-line tool via Python's `subprocess` module. It creates a temporary file with a known typo, first checks for the typo, and then applies fixes. The `typos` tool exits with a status code of 0 if no typos are found, and 2 if typos are found and/or fixed.

import subprocess import os # Create a dummy file with a known typo file_content = """\n# This is a comment with a common typo: recievice\ndef foo(arguemnt):\n # Some code\n pass\n""" with open("temp_code.py", "w") as f: f.write(file_content) print("--- Original file content ---") print(file_content) # 1. Check for typos (will exit with code 2 if typos found) print("\n--- Checking for typos ---") try: # Using check=True will raise CalledProcessError if typos are found (exit code 2) result = subprocess.run(['typos', 'temp_code.py'], capture_output=True, text=True, check=False) print(result.stdout) if result.returncode == 0: print("No typos found.") elif result.returncode == 2: print("Typos found (exit code 2).") else: print(f"Error during check: {result.stderr}") except FileNotFoundError: print("Error: 'typos' command not found. Ensure it's installed and in your PATH.") # 2. Fix typos in place print("\n--- Fixing typos ---") try: fix_result = subprocess.run(['typos', '--write-changes', 'temp_code.py'], capture_output=True, text=True, check=False) if fix_result.returncode == 0: print("Typos fixed successfully.") elif fix_result.returncode == 2: print("Typos fixed (some might remain if ambiguous).") else: print(f"Error during fix: {fix_result.stderr}") print("\n--- File content after fixing ---") with open("temp_code.py", "r") as f: fixed_content = f.read() print(fixed_content) finally: # Clean up the dummy file if os.path.exists("temp_code.py"): os.remove("temp_code.py")
typos --version
Debug
Known issues
gotchaThe `typos` Python package is a wrapper around a Rust-based binary. Its primary interface is the command-line interface (CLI). Direct programmatic access via `import typos` to Python functions/classes for core spell-checking logic is generally not available, and interaction is typically done by calling the `typos` executable via `subprocess`.
fix
Interact with `typos` using `subprocess.run()` to execute CLI commands (e.g., `typos file.py`, `typos --write-changes file.py`) and parse its `stdout` or `stderr` for results. Alternatively, integrate `typos` directly into CI/CD pipelines or `pre-commit` hooks.
affects: All versions
gotchaConfiguration for `typos` is primarily managed through TOML files like `_typos.toml` or `typos.toml` in your project's root or parent directories, not through Python code. These files allow you to define custom dictionaries, ignore patterns, and exclude files.
fix
Create and manage a `_typos.toml` or `typos.toml` file at the root of your project to customize `typos` behavior. Refer to the official GitHub repository for detailed configuration options.
affects: All versions
gotcha`typos` operates on a 'known misspellings' dictionary, meaning it only corrects errors it explicitly recognizes, rather than attempting to guess corrections for any word not in a dictionary. This design leads to a very low false-positive rate but may not catch every possible typo if it's not in its internal list of known errors.
fix
Understand that `typos` prioritizes low false positives for automated workflows. If you need to catch specific 'valid but unusual' words as typos, you may need to extend its dictionary via `_typos.toml` or use a different spell checker that employs a larger general dictionary approach.
affects: All versions
gotchaWhen running `typos` in a `subprocess` and `check=True` is used, a `CalledProcessError` will be raised if `typos` finds any errors (returns exit code 2). This is standard behavior for `subprocess.run` when the command exits with a non-zero status, but it signifies 'typos found', not necessarily an execution error of the `typos` tool itself.
fix
Handle `subprocess.CalledProcessError` (or set `check=False`) and inspect `result.returncode` explicitly. A `returncode` of 0 means no typos were found, and 2 means typos were detected (and potentially fixed if `--write-changes` was used).
affects: All versions
Errors
Common errors & fixes
typos: command not found
The `typos` executable script is not in your system's PATH, typically because the directory where `pip` installs scripts is not included.
fix
Ensure the directory containing Python scripts (e.g., `~/.local/bin` on Linux/macOS, or the `Scripts` folder in your virtual environment) is added to your system's PATH. Alternatively, run `python -m typos`.
error: failed to run custom build command for `typos-cli vX.Y.Z`
The `typos` Python package bundles a Rust binary, and this error occurs when `pip install` fails to compile the Rust component, often due to a missing or misconfigured Rust toolchain (Rustup, Cargo, `rustc`).
fix
Install the Rust toolchain by following instructions on `rustup.rs` (e.g., `curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh`), then retry `pip install typos`.
ModuleNotFoundError: No module named 'typos'
The `typos` Python package has not been installed in the current Python environment or the environment where your script is attempting to import it.
fix
Install the package using `pip install typos` in your active Python environment.
Error: failed to parse config file 'typos.toml'
The `typos.toml` configuration file contains a syntax error (e.g., incorrect TOML format, invalid characters) or refers to non-existent paths, preventing `typos` from loading its configuration.
fix
Review your `typos.toml` file carefully, correcting any TOML syntax errors or ensuring all paths specified within it are valid and accessible. Refer to the official `typos` configuration documentation for correct syntax examples.
Upgrade
Version history
1.50.0latest on PyPI · released Aug 28, 2026
Audit
Dependencies

No dependency data recorded yet.

Agent activity
14 hits · last 30 days
node
10
Resources