Skip to main content
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

$ 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.

Release files for eradicate 3.0.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for eradicate 3.0.1
File Size Uploaded
eradicate-3.0.1.tar.gz 8.9 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for eradicate 3.0.1
File Interpreter ABI Platform
eradicate-3.0.1-py3-none-any.whl Python 3 none any Details

Total release size:15.2 kB

Release files / eradicate-3.0.1.tar.gz

Download URL eradicate-3.0.1.tar.gz
Size 8.9 kB
Tags Source
SHA-256 checksum
How to use checksums
c9cb7ef8e7e83c3fbd9806010e21089892bb649531c68875a555c7b5c978faa6
BLAKE2b-256 checksum
How to use checksums
95f840f8032395534e7441f4d05da63300e869823a6040d33a87a1863394e496
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.11.9

Release files / eradicate-3.0.1-py3-none-any.whl

Download URL eradicate-3.0.1-py3-none-any.whl
Size 6.3 kB
Tags Python 3
SHA-256 checksum
How to use checksums
1037f0aa969b716b6dfc30fa9289f8e2ea6a999c95b487073193ab4844db7fa5
BLAKE2b-256 checksum
How to use checksums
59b59690d52f90f2954ba2c8a7818dcee3e78021d5eb3a3dc93d49b2837cf0b9
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.11.9

Release history Release notifications | RSS feed

This release

3.0.1 This release

2 release files

3.0.0

2 release files

2.3.0

2 release files

2.2.0

2 release files

2.1.0

2 release files

2.0.0

1 release file

1.0

1 release file

0.2.1

1 release file

0.2

1 release file

0.1.6

1 release file

0.1.5

1 release file

0.1.4

1 release file

0.1.3

1 release file

0.1.2

1 release file

0.1.1

1 release file

0.1

1 release file

0.0.5

1 release file

0.0.4

1 release file

0.0.3

1 release file

0.0.2

1 release file

0.0.1

1 release file

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page