skillfed

eradicate

Removes commented-out code.

eradicate v3.0.1 972.2K downloads/30d#4,608 on PyPI220
Permissive license Expat License Active released

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 eradicate

uv

uv add eradicate

poetry

poetry add eradicate

Installing 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

Environment :: ConsoleIntended Audience :: DevelopersLicense :: OSI Approved :: MIT LicenseProgramming Language :: Python :: 3Programming Language :: Python :: 3 :: OnlyTopic :: Software Development :: Quality Assurance

Tags

remove commented codeclean up commented-out codedetect dead code commentspython code cleanup toolcommented code removalcode comment sanitizerdead code detection
code-cleanuplinting-adjacent

More Quality Assurance packages