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 typosVerified import paths — ran on the pinned version, not inferred.
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.
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.
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.
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.
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).
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`.
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`.
Install the package using `pip install typos` in your active Python environment.
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.
No dependency data recorded yet.