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.2.0.tar.gz
.
File metadata
- Download URL: eradicate-2.2.0.tar.gz
- Upload date:
- Size: 6.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.10.0
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | c329a05def6a4b558dab58bb1b694f5209706b7c99ba174d226dfdb69a5ba0da |
|
MD5 | c848e8fde89f57782b3da4314201d908 |
|
BLAKE2b-256 | 6ca7cc917ac6fcd91e9fcb4ff2a1137e20ededbad15377527b7f23536a96e736 |
File details
Details for the file eradicate-2.2.0-py3-none-any.whl
.
File metadata
- Download URL: eradicate-2.2.0-py3-none-any.whl
- Upload date:
- Size: 6.9 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.10.0
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 751813c315a48ce7e3d0483410991015342d380a956e86e0265c61bfb875bcbc |
|
MD5 | 9a3a6b221f6876da21fdf2496822e595 |
|
BLAKE2b-256 | 8f3d96f6fdf6104556ac294c2fac94a9fd132d0c1187883a1d3de6be77b95017 |