eradicate
Removes commented-out code.
What it is and what it does
Eradicate is a command-line tool that scans Python source files for block comments containing valid Python syntax and removes those likely to be commented-out code. It uses heuristics to avoid false positives—for example, it won't remove comments that are natural language sentences. The tool is designed for teams using modern version control who want to clean up accumulated commented-out code without manually reviewing each instance.
The package works by analyzing comment blocks for Python syntax patterns and filtering out obvious non-code comments. It includes a whitelist feature to handle false positives by allowing users to specify regex patterns (via --whitelist or --whitelist-extend) that should be preserved. It integrates with linting workflows and has companion plugins for flake8 and other tools.
Use it for:
- Clean up legacy codebases that accumulated commented-out code over time before committing to version control
- Enforce code cleanliness in CI/CD pipelines by detecting and removing dead comments automatically
- Prepare code for code review by removing noise and improving readability of comment sections
- Integrate with pre-commit hooks to prevent commented-out code from entering the repository
- Audit existing Python projects to identify and remove debugging or experimental code left as comments
Worth the install?
AI-flagged interpretation of the facts on this page — verify before relying
Eradicate detects and removes commented-out code from Python files while preserving legitimate comments, using heuristics to distinguish between the two.
Yes. Eradicate is a lightweight, actively maintained tool with zero dependencies, permissive licensing, and a clear single purpose. It's useful for teams that want to enforce clean code practices and remove commented-out code at scale. Install it if you maintain Python codebases and want to automate comment cleanup; the low friction and focused scope make it a low-risk addition to your workflow.
Install
eradicate on PyPI
pip
pip install eradicateuv
uv add eradicatepoetry
poetry add eradicateInstalling eradicate
Before you install
Low install friction with no runtime dependencies. Actively maintained as of 2025-10-27 with recent commits and a stable repository.
License in practice
Licensed under the Expat License (MIT equivalent), a permissive license that allows free use, modification, and distribution with minimal restrictions.
Quickstart
pip install eradicate
eradicate --in-place example.py
Verify before relying
- Accuracy of heuristics for distinguishing commented code from legitimate comments in edge cases
- Performance characteristics on large codebases or files with many comments
Package facts
| License | Expat License (permissive) |
| Python support | not specified |
| Install friction | low — pure-Python wheel |
| Runtime dependencies | none |
| Maintenance | actively maintained — 291 days since the last release |
| Last repo commit | |
| First released | |
| Downloads | 972,232/month — #4,608 on PyPI (30-day window, as of 2026-08-14) |
| Known vulnerabilities | none known (OSV.dev, checked 2026-08-14) |
Evidence: eradicate-3.0.1-py3-none-any.whl
Keywords: clean, format, commented-out code
Tags
More Quality Assurance packages
Coverage.py measures which lines of Python code…
permissive · top 1,000 on PyPI
ruffRuff is a Python linter and code formatter…
permissive · top 1,000 on PyPI
pexpectPexpect spawns and controls interactive console…
permissive · top 1,000 on PyPI
blackBlack reformats Python source code to a…
permissive · top 1,000 on PyPI
pytest-xdistpytest-xdist distributes pytest tests across…
permissive · top 1,000 on PyPI
cfn-lintValidates AWS CloudFormation templates in YAML…
permissive · top 1,000 on PyPI
flake8-eradicateA flake8 plugin that detects commented-out code…
permissive · top 15,000 on PyPI
vultureVulture is a static code analyzer that finds…
permissive · top 5,000 on PyPI
uncalledDetects unused functions in Python projects…
permissive · top 15,000 on PyPI
deadcodeScans Python codebases to find and optionally…
agpl · top 15,000 on PyPI
yesqayesqa automatically removes unnecessary `#…
permissive · top 15,000 on PyPI
sanitize-filenameRemoves or replaces problematic characters from…
permissive · top 15,000 on PyPI
comment-parserExtracts comments from source code files across…
permissive · top 15,000 on PyPI
commented-configparserExtends Python's standard ConfigParser to…
permissive · top 15,000 on PyPI
autoflakeautoflake removes unused imports and unused…
permissive · top 5,000 on PyPI
pathvalidateSanitize and validate filenames and file paths…
permissive · top 5,000 on PyPI