Remove debugger

Python pattern

We should remove debugger from production code


Apply with the Grit CLI
grit apply py_no_debugger

Remove debugger direct as import

BEFORE
import pdb as db


def foo():
    # BAD: pdb-remove
    db.set_trace()

    a = "apple"

    db = "the string, not the library"
    #ok:pdb-remove
    pdb = "also a string"
    # BAD: pdb-remove
    pdb.Pdb.set_trace()
    # BAD: pdb-remove
    db.Pdb.set_trace(...)
AFTER
import pdb as db


def foo():
    # BAD: pdb-remove

    a = "apple"

    db = "the string, not the library"
    #ok:pdb-remove
    pdb = "also a string"
    # BAD: pdb-remove
    # BAD: pdb-remove

Remove debugger direct import

BEFORE
# BAD: python-debugger-found
import pdb

# BAD: python-debugger-found
pdb.set_trace()


def foo():
    # GOOD: python-debugger-found
    p = not_pdb.set_trace()
AFTER
# BAD: python-debugger-found
import pdb

# BAD: python-debugger-found


def foo():
    # GOOD: python-debugger-found
    p = not_pdb.set_trace()