Registry / testing / flake8-eradicate

flake8-eradicate

JSON →
library1.5.0pypypi✓ verified 23d ago

flake8-eradicate is a Flake8 plugin designed to identify and flag commented-out code within your Python projects. It helps enforce code cleanliness by pointing out code that might be dead, unused, or temporarily disabled. The current version is 1.5.0, and it maintains an active release cadence, typically releasing updates every few months to support newer Python and Flake8 versions.

pip install flake8-eradicate
INSTALL
IMPORT
SIG · FLAKE8-ERADICATE
F
flake8-eradicate
testingpythonv1.5.0
Install
1.9s avg
Import
Disk
18MB
Pass rate
10/ 10
Env Coverage10 / 10
glibc
3.93.13
musl
3.93.13
Install & Compatibility
Where this runs
tested against v1.5.0 · 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.000s · 19.9MB
glibc
py 3.103.95 runs
installs and imports cleanly · install 1.9s · import 0.000s · 20MB
18MB installed
● package 18MB
Code
Verified usage

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

flake8-eradicate as a plugin
This is a flake8 plugin and does not require direct Python imports in user code. It integrates automatically with flake8 upon installation.
Users install the package and run `flake8` from the command line; no `from ... import ...` is needed for its functionality.

To use flake8-eradicate, simply install it alongside flake8. The plugin automatically registers itself, and subsequent runs of `flake8` will include checks for commented-out code, reporting them as E7901 errors.

# 1. Install flake8 and flake8-eradicate pip install flake8 flake8-eradicate # 2. Create a Python file with commented-out code (e.g., example.py) # def old_function(): # print('This is old code') def new_function(): print('This is new code') # old_function() # 3. Run flake8 on your project # It will automatically detect and use the flake8-eradicate plugin. # The default error code is E7901. # Expected output: example.py:3:5: E7901 Found commented out code import os if os.getenv('RUN_FLAKE8_EXAMPLE', 'false').lower() == 'true': # In a real scenario, you'd run this from your terminal # For this example, we simulate the effect by creating a dummy file # and noting the expected output. with open('temp_example.py', 'w') as f: f.write("# def old_function():\n# print('This is old code')\n\ndef new_function():\n print('This is new code')\n\n# old_function()") print("To run, save the code to 'example.py' and execute: 'flake8 example.py'") print("Expected output (or similar): 'example.py:3:5: E7901 Found commented out code'") # You would typically run 'flake8 temp_example.py' in a shell.
Debug
Known issues
breakingPython 3.6 support was dropped in version 1.4.0.
fix
Upgrade your Python environment to version 3.8 or newer. The library's `requires_python` specifies `>=3.8,<4.0`.
affects: >=1.4.0
gotchaThe plugin is designed to find *commented-out code blocks*, not just any comments. It targets code that appears to be disabled or left in comments, not descriptive comments.
fix
Understand that the plugin aims to identify potential dead code. If you have valid, non-code comments that trigger the rule, you might need to adjust your commenting style or use the whitelisting options.
affects: all
gotchaCompatibility with `flake8` versions has evolved. Version 1.2.0 added support for `flake8@4.0.0`, and version 1.3.0 added support for `flake8@5.0`.
fix
Ensure your `flake8` installation is relatively up-to-date, preferably `4.0.0` or `5.0.0` or newer, to guarantee full compatibility and access to the latest features and fixes.
affects: <1.3.0
gotchaFine-tuning which commented-out code is ignored can be done using CLI options, which were introduced in version 1.0.0.
fix
Utilize `--eradicate-whitelist <pattern>` and `--eradicate-whitelist-append <pattern>` options to specify regular expressions for paths to ignore. This helps in managing false positives or intentional commented code.
affects: <1.0.0
Upgrade
Version history
1.5.0latest on PyPI · released May 31, 2023
Audit
Dependencies
flake8requiredThis is a plugin for Flake8 and requires Flake8 to function. It supports Flake8 4.0.0+.
Agent activity
5 hits · last 30 days
node
4
Resources
flake8-eradicate — pip install flake8-eradicate · libregistry