Registry / testing / eradicate

eradicate

JSON →
library3.0.1pypypi✓ verified 23d ago

Eradicate is a Python library and command-line tool designed to remove commented-out code from Python files. It identifies block comments that contain valid Python syntax, which are likely to be old, commented-out code, helping to clean up repositories. It aims to avoid false positives by intelligently detecting code patterns within comments. The library is actively maintained, with version 3.0.1 released recently, focusing on Python version compatibility and continuous improvements.

pip install eradicate
INSTALL
IMPORT
SIG · ERADICATE
E
eradicate
testingpythonv3.0.1
Install
1.6s avg
Import
24ms
Disk
16MB
Pass rate
10/ 10
Env Coverage10 / 10
glibc
3.93.13
musl
3.93.13
Install & Compatibility
Where this runs
tested against v3.0.1 · 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.026s · 17.8MB
glibc
py 3.103.95 runs
installs and imports cleanly · install 1.6s · import 0.022s · 18MB
16MB installed
● package 16MB
Code
Verified usage

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

eradicate
import eradicate
While 'import eradicate' is correct, the primary usage of this library is via its command-line interface rather than direct programmatic API calls in typical scenarios.

Eradicate is predominantly used as a command-line tool. This example demonstrates how to create a sample Python file with commented-out code and then use `eradicate --in-place` to clean it up. The `--in-place` flag modifies the file directly.

echo "# import os\na = 4\n#print('hello')" > example.py eradicate --in-place example.py cat example.py # Expected output of example.py: # a = 4 #
eradicate --version
Debug
Known issues
breakingVersion 3.0.0 dropped support for Python 2.7, 3.6, 3.7, and 3.8. Users on these older Python versions must remain on `eradicate` < 3.0.0.
fix
Upgrade to Python 3.9 or newer, or pin `eradicate` to a version prior to 3.0.0 (e.g., `pip install 'eradicate<3.0.0'`).
affects: < 3.0.0 to 3.0.0+
breakingVersion 2.0.0 introduced a 'New class-based API'. While `eradicate` is primarily a CLI tool, direct programmatic users relying on older internal APIs might experience breaking changes.
fix
Review your code for direct imports and usage of `eradicate`'s internal modules. Prefer using the command-line interface or integrations like `flake8-eradicate` if possible. If programmatic use is necessary, consult the `eradicate` source for the updated API.
affects: < 2.0.0 to 2.0.0+
gotchaEradicate might occasionally produce false positives (removing legitimate comments) or false negatives (missing actual commented-out code).
fix
Utilize the `--whitelist` or `--whitelist-extend` CLI options to specify regex patterns for comments that should always be ignored or preserved. Review changes carefully after running `eradicate`.
affects: All versions
Errors
Common errors & fixes
ModuleNotFoundError: No module named 'eradicate'
The 'eradicate' library is not installed in your current Python environment, or the Python interpreter cannot find it in its search paths.
fix
Install the library using pip: `pip install eradicate`
eradicate: command not found
The `eradicate` command-line tool's executable is not in your system's PATH, or the installation was not successful, preventing direct execution from the terminal. This can also appear as ''eradicate' is not recognized as an internal or external command, operable program or batch file' on Windows.
fix
Ensure `eradicate` is installed and its script is in your PATH. Alternatively, run it using the Python module runner: `python -m eradicate <your_file.py>`
FileNotFoundError: [Errno 2] No such file or directory: 'your_file.py'
You are attempting to run `eradicate` on a file or directory that does not exist at the specified path.
fix
Double-check the spelling and the absolute or relative path to the file/directory you want to process. Ensure the file exists before running the command.
SyntaxError: invalid syntax (when running eradicate on older Python versions)
Eradicate version 3.0.0 and later dropped support for Python 2.7, 3.6, 3.7, and 3.8. Running a newer version of `eradicate` on these older Python environments can lead to syntax errors due to incompatible language features.
fix
Upgrade your Python environment to 3.9 or newer (`eradicate` 3.x requires Python 3.9+). If upgrading Python is not an option, you must pin `eradicate` to an older compatible version: `pip install 'eradicate<3.0.0'`.
Upgrade
Version history
3.0.1latest on PyPI · released Oct 27, 2025
Audit
Dependencies

No dependency data recorded yet.

Agent activity
14 hits · last 30 days
node
12
Resources
eradicate — pip install eradicate · libregistry