Removes commented-out code.
Project description
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
$ eradicate --in-place example.py
Before running eradicate.
#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 False
After running eradicate.
a = 4
def foo(x, y, z):
print(x, y, z)
# This is a real comment.
return False
Whitelisting
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.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file eradicate-2.3.0.tar.gz
.
File metadata
- Download URL: eradicate-2.3.0.tar.gz
- Upload date:
- Size: 8.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.11.3
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 06df115be3b87d0fc1c483db22a2ebb12bcf40585722810d809cc770f5031c37 |
|
MD5 | a66b08ef034cac011866debb84ba1a60 |
|
BLAKE2b-256 | 7ae1665186aedea2d6ebf0415cf97c0629c8123a721e7afc417deeade5598215 |
File details
Details for the file eradicate-2.3.0-py3-none-any.whl
.
File metadata
- Download URL: eradicate-2.3.0-py3-none-any.whl
- Upload date:
- Size: 6.1 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.11.3
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 2b29b3dd27171f209e4ddd8204b70c02f0682ae95eecb353f10e8d72b149c63e |
|
MD5 | 7658cbd17015e3c7fed0b9906c339dd2 |
|
BLAKE2b-256 | 90c2533e1338429aeba1f089566a2314d69d3e78ab57a73006f16a923bf2b24c |