{"id":4538,"library":"flake8-eradicate","title":"flake8-eradicate","description":"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.","status":"active","version":"1.5.0","language":"en","source_language":"en","source_url":"https://github.com/wemake-services/flake8-eradicate","tags":["flake8","linter","code quality","static analysis","python"],"install":[{"cmd":"pip install flake8-eradicate","lang":"bash","label":"Install with pip"}],"dependencies":[{"reason":"This is a plugin for Flake8 and requires Flake8 to function. It supports Flake8 4.0.0+.","package":"flake8","optional":false}],"imports":[{"note":"Users install the package and run `flake8` from the command line; no `from ... import ...` is needed for its functionality.","symbol":"flake8-eradicate as a plugin","correct":"This is a flake8 plugin and does not require direct Python imports in user code. It integrates automatically with flake8 upon installation."}],"quickstart":{"code":"# 1. Install flake8 and flake8-eradicate\npip install flake8 flake8-eradicate\n\n# 2. Create a Python file with commented-out code (e.g., example.py)\n#    def old_function():\n#        print('This is old code')\n\ndef new_function():\n    print('This is new code')\n\n#    old_function()\n\n# 3. Run flake8 on your project\n#    It will automatically detect and use the flake8-eradicate plugin.\n#    The default error code is E7901.\n#    Expected output: example.py:3:5: E7901 Found commented out code\nimport os\nif os.getenv('RUN_FLAKE8_EXAMPLE', 'false').lower() == 'true':\n    # In a real scenario, you'd run this from your terminal\n    # For this example, we simulate the effect by creating a dummy file\n    # and noting the expected output.\n    with open('temp_example.py', 'w') as f:\n        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()\")\n    print(\"To run, save the code to 'example.py' and execute: 'flake8 example.py'\")\n    print(\"Expected output (or similar): 'example.py:3:5: E7901 Found commented out code'\")\n    # You would typically run 'flake8 temp_example.py' in a shell.","lang":"python","description":"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."},"warnings":[{"fix":"Upgrade your Python environment to version 3.8 or newer. The library's `requires_python` specifies `>=3.8,<4.0`.","message":"Python 3.6 support was dropped in version 1.4.0.","severity":"breaking","affected_versions":">=1.4.0"},{"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.","message":"The 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.","severity":"gotcha","affected_versions":"all"},{"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.","message":"Compatibility 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`.","severity":"gotcha","affected_versions":"<1.3.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.","message":"Fine-tuning which commented-out code is ignored can be done using CLI options, which were introduced in version 1.0.0.","severity":"gotcha","affected_versions":"<1.0.0"}],"env_vars":null,"last_verified":"2026-04-12T00:00:00.000Z","next_check":"2026-07-11T00:00:00.000Z"}