Registry / devops / codespell

codespell

JSON →
library2.4.2pypypiunverified

Codespell is a Python command-line tool designed to find and fix common misspellings in text files, primarily within source code. It operates using a curated dictionary of common typos and their corrections, aiming to reduce false positives that typical spell checkers might produce with technical terms or variable names. The library is actively maintained and frequently integrated into CI/CD pipelines and pre-commit hooks for automated code quality checks.

pip install codespell
INSTALL
IMPORT
SIG · CODESPELL
C
codespell
devopspythonv2.4.2
harness data pending
Install & Compatibility
Where this runs

No compatibility data collected yet for this library.

Code
Verified usage

To get started, run `codespell` from your terminal in the directory you wish to check. By default, it performs a dry run, listing potential misspellings. Use the `-i` flag for interactive mode to review and confirm changes, or `-w` to automatically apply corrections (use with caution).

# Check for misspellings in the current directory (dry run) codespell . # Check specific files or directories (dry run) codespell my_project/README.md my_project/src/ # Interactively fix misspellings in a directory (recommended for review) codespell -i 3 my_project/ # Automatically write corrections to files (use with caution or after review) codespell -w my_project/
codespell --version
Debug
Known issues
gotchaUsing the `--write-changes` (`-w`) flag without interactive mode (`-i`) can lead to unintended automatic corrections of valid but non-standard spellings or technical jargon. It's highly recommended to use `--interactive` (`-i 2` or `-i 3`) to review suggested changes before applying them.
fix
Always run `codespell` with `-i` (e.g., `codespell -i 3 .`) when planning to apply fixes, or review the dry run output thoroughly before using `-w`.
affects: All versions
gotchaAfter installing `codespell` with `pip`, the executable might not be directly available in your system's `$PATH`. This often happens if pip installs packages to a user-specific binary directory like `~/.local/bin`.
fix
Ensure that `~/.local/bin` is included in your system's `$PATH` environment variable. You might need to add `export PATH="$HOME/.local/bin:$PATH"` to your shell's configuration file (e.g., `.bashrc`, `.zshrc`).
affects: All versions
breakingWhen `pyproject.toml` is used for configuration, Python versions prior to 3.11 require the `tomli` library to be installed. Without `tomli`, `codespell` will fail to read its configuration.
fix
If you are using Python < 3.11 and configure `codespell` via `pyproject.toml`, ensure `pip install tomli` is executed. Python 3.11 and later include `tomli` in the standard library.
affects: < 3.11 (with pyproject.toml config)
gotchaWhen defining custom dictionary entries with multiple suggested fixes (e.g., `fiel->feel, field, file, phial,`), a trailing comma is crucial. If omitted, the last suggestion in the list will be discarded.
fix
Always include a trailing comma after the last suggestion when defining dictionary entries with multiple corrections. Refer to the dictionary format documentation for details.
affects: All versions
Errors
Common errors & fixes
codespell: command not found
The `codespell` executable's installation directory is not included in the system's PATH environment variable, or `codespell` was not installed correctly in the active environment.
fix
Add the Python user scripts directory (e.g., `~/.local/bin` on Linux/macOS or `%APPDATA%\Python\Scripts` on Windows) to your system's PATH, or ensure `codespell` is installed in the active virtual environment by running `pip install codespell`.
FileNotFoundError: [Errno 2] No such file or directory: 'codespell'
This error often occurs when `codespell` is called from a script or an automated environment (like a pre-commit hook or CI/CD pipeline) where the `codespell` executable is not found in the `PATH` of that specific execution environment.
fix
Ensure `codespell` is installed within the environment where it's being called (e.g., the virtual environment for a pre-commit hook) and that the system's PATH includes the directory where `codespell` is installed. For pre-commit, verify the `rev` in `.pre-commit-config.yaml` is correct and allow `pre-commit` to manage its environment.
UnicodeDecodeError: 'charmap' codec can't decode byte 0xXX in position Y: character maps to <undefined>
`codespell` attempted to read a file with an encoding (e.g., UTF-8) that differs from the system's default or the encoding `codespell` is currently using to interpret the file.
fix
Explicitly specify the correct file encoding using the `--encoding` flag (e.g., `codespell --encoding=utf-8 your_file.py`) or configure `codespell` to detect encoding automatically if supported by your version.
codespell reports valid words as misspellings (false positives)
`codespell`'s default dictionaries do not recognize specific technical terms, proper nouns, or project-specific jargon as valid words, leading to them being flagged as misspellings.
fix
Ignore specific words using the `-L` flag (e.g., `codespell -L yourword,anotherword`), by providing a file with words to ignore via `-I` (e.g., `codespell -I .codespellignore`), or by configuring `ignore-words-list` in a `.codespellrc` or `pyproject.toml` configuration file for persistent project-wide ignores.
Upgrade
Version history
2.4.2latest on PyPI · released Mar 5, 2026
Audit
Dependencies
pythonrequiredCodespell requires Python 3.9 or above.
tomlioptionalRequired for Python versions prior to 3.11 when configuring codespell via a pyproject.toml file.
Agent activity
23 hits · last 30 days
node
20
OpenAI (training)
1
Resources
codespell — pip install codespell · libregistry