Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/PyCQA/eradicate
Removes commented-out code from Python files
https://github.com/PyCQA/eradicate
Last synced: about 2 months ago
JSON representation
Removes commented-out code from Python files
- Host: GitHub
- URL: https://github.com/PyCQA/eradicate
- Owner: PyCQA
- Created: 2012-12-23T04:39:48.000Z (almost 12 years ago)
- Default Branch: master
- Last Pushed: 2024-04-22T21:33:15.000Z (8 months ago)
- Last Synced: 2024-05-21T01:13:33.212Z (7 months ago)
- Language: Python
- Homepage: https://pypi.python.org/pypi/eradicate
- Size: 119 KB
- Stars: 197
- Watchers: 5
- Forks: 24
- Open Issues: 7
-
Metadata Files:
- Readme: README.rst
Awesome Lists containing this project
- awesome-python-code-formatters - eradicate - out code from Python files. (UNIX-way formatters)
- starred-awesome - eradicate - Removes commented-out code from Python files (Python)
README
=========
eradicate
=========.. image:: https://github.com/myint/eradicate/actions/workflows/test.yml/badge.svg
:target: https://github.com/myint/eradicate/actions/workflows/test.yml
:alt: Build status----
``eradicate`` removes commented-out code from Python files.
Introduction
============With modern revision control available, there is no reason to save
commented-out code to your repository. ``eradicate`` helps cleans up
existing junk comments. It does this by detecting block comments that
contain valid Python syntax that are likely to be commented out code.
(It avoids false positives like the sentence ``this is not good``,
which is valid Python syntax, but is probably not code.)Example
=======.. code-block:: bash
$ eradicate --in-place example.py
Before running ``eradicate``.
.. code-block:: python
#import os
# from foo import junk
#a = 3
a = 4
#foo(1, 2, 3)def foo(x, y, z):
# print('hello')
print(x, y, z)# This is a real comment.
#return True
return FalseAfter running ``eradicate``.
.. code-block:: python
a = 4
def foo(x, y, z):
print(x, y, z)# This is a real comment.
return FalseWhitelisting
============False positives can happen so there is a whitelist feature to fix them shorthand.
You can either add entries to the default whitelist with ``--whitelist-extend`` or overwrite the default with ``--whitelist``.
Both arguments expect a string of ``#`` separated regex strings (whitespaces are preserved). E.g. ``eradicate --whitelist "foo#b a r" filename``
Those regex strings are matched case insensitive against the start of the comment itself.For the default whitelist please see ``eradicate.py``.
Related
=======There are different tools, plugins, and integrations for ``eradicate`` users:
- `flake8-eradicate `_ - Flake8 plugin to find commented out or dead code.
- `databricks-labs-pylint `_ - Databricks-specific PyLint plugin, that can also find commented out code.