eradicate: Remove Commented-Out Code

3.0.1 · active · verified Sun Apr 12

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.

Warnings

Install

Imports

Quickstart

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
#

view raw JSON →