{"id":4528,"library":"eradicate","title":"eradicate: Remove Commented-Out Code","description":"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.","status":"active","version":"3.0.1","language":"en","source_language":"en","source_url":"https://github.com/pycqa/eradicate","tags":["code quality","linter","static analysis","refactoring","cli"],"install":[{"cmd":"pip install eradicate","lang":"bash","label":"Install latest version"}],"dependencies":[],"imports":[{"note":"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.","symbol":"eradicate","correct":"import eradicate"}],"quickstart":{"code":"echo \"# import os\\na = 4\\n#print('hello')\" > example.py\neradicate --in-place example.py\ncat example.py\n# Expected output of example.py: \n# a = 4\n#","lang":"bash","description":"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."},"warnings":[{"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'`).","message":"Version 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.","severity":"breaking","affected_versions":"< 3.0.0 to 3.0.0+"},{"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.","message":"Version 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.","severity":"breaking","affected_versions":"< 2.0.0 to 2.0.0+"},{"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`.","message":"Eradicate might occasionally produce false positives (removing legitimate comments) or false negatives (missing actual commented-out code).","severity":"gotcha","affected_versions":"All versions"}],"env_vars":null,"last_verified":"2026-04-12T00:00:00.000Z","next_check":"2026-07-11T00:00:00.000Z"}