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-2.1.0.tar.gz (6.0 kB view details)

Uploaded Source

Built Distribution

eradicate-2.1.0-py3-none-any.whl (6.9 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: eradicate-2.1.0.tar.gz
  • Upload date:
  • Size: 6.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.0 CPython/3.9.9

File hashes

Hashes for eradicate-2.1.0.tar.gz
Algorithm Hash digest
SHA256 aac7384ab25b1bf21c4c012de9b4bf8398945a14c98c911545b2ea50ab558014
MD5 4738597a1511ba8dfbcb74ad83aca509
BLAKE2b-256 c1ad3bd6d9de4cc1d77d52342a235f6d019945474b92b36fe9cbbb7f8569d009

See more details on using hashes here.

File details

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

File metadata

  • Download URL: eradicate-2.1.0-py3-none-any.whl
  • Upload date:
  • Size: 6.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.0 CPython/3.9.9

File hashes

Hashes for eradicate-2.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 8bfaca181db9227dc88bdbce4d051a9627604c2243e7d85324f6d6ce0fd08bb2
MD5 908eed97e24022d3859b714cb0ba57cd
BLAKE2b-256 9657dc767edd8a3ba8d2d4f5b81f19305160e984606320d1f7769b3b8cbe2b19

See more details on using hashes here.

Supported by

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