Skip to main content

Removes commented-out code.

Project description

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.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

eradicate-3.0.1.tar.gz (8.9 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

eradicate-3.0.1-py3-none-any.whl (6.3 kB view details)

Uploaded Python 3

File details

Details for the file eradicate-3.0.1.tar.gz.

File metadata

  • Download URL: eradicate-3.0.1.tar.gz
  • Upload date:
  • Size: 8.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.11.9

File hashes

Hashes for eradicate-3.0.1.tar.gz
Algorithm Hash digest
SHA256 c9cb7ef8e7e83c3fbd9806010e21089892bb649531c68875a555c7b5c978faa6
MD5 25aaf07a0cd0736bbe805c8af3d67473
BLAKE2b-256 95f840f8032395534e7441f4d05da63300e869823a6040d33a87a1863394e496

See more details on using hashes here.

File details

Details for the file eradicate-3.0.1-py3-none-any.whl.

File metadata

  • Download URL: eradicate-3.0.1-py3-none-any.whl
  • Upload date:
  • Size: 6.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.11.9

File hashes

Hashes for eradicate-3.0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 1037f0aa969b716b6dfc30fa9289f8e2ea6a999c95b487073193ab4844db7fa5
MD5 97a04e84d570e281d3bec0caff965b40
BLAKE2b-256 59b59690d52f90f2954ba2c8a7818dcee3e78021d5eb3a3dc93d49b2837cf0b9

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page