Skip to main content

SKY-L009 · Logic and resilience

Debug leftover

Varies

The catalog gives no severity. A debugger call (breakpoint(), pdb.set_trace() and similar) or ic() is HIGH; a print() that looks like debugging output is LOW.

A call left over from debugging. It can be a breakpoint() or pdb.set_trace() that stops the program, an ic() from the icecream library, or a print() that dumps a variable with a DEBUG label or the {value=} f-string form.

Languages
Python
Quality gate
counted toward the gate limits (full and diff scans)
Finding type
review
Wrong result? Report itA false positive, a missed case or a confusing message: it goes privately to the founder.

Why it matters

A forgotten breakpoint() freezes the request or job that reaches it: a web worker waits forever for someone to type at a debugger prompt that nobody can see. Debug prints can also write order details or user data to logs that are kept and shared.

What Skylos flags

shop/checkout.py · PythonReported on line 8
"""Apply promotion codes at checkout.""" from shop.promotions import lookup_discount  def apply_discount(order, code):    discount = lookup_discount(code)    breakpoint()    order.total = max(order.total - discount, 0)    return order

What Skylos leaves alone

shop/checkout.py · Python
"""Apply promotion codes at checkout.""" from shop.promotions import lookup_discount  def apply_discount(order, code):    discount = lookup_discount(code)    print(f"Applied {code}: {discount} off order {order.id}")    order.total = max(order.total - discount, 0)    return order

Why Skylos leaves it alone

A plain print() is ordinary output: command-line tools and scripts print on purpose. Skylos only reports a print() that carries evidence of debugging, such as a DEBUG: label, {discount=} or a dump of locals(). A logger is still the better choice in library code.

How Skylos decides

  1. Runs with --quality on Python files, test files included. Looks at every function call.
  2. Reports HIGH for breakpoint() and ic() written as bare names, and for pdb.set_trace(), ipdb.set_trace(), pudb.set_trace() and code.interact().
  3. Reports LOW for print(), pprint(), pprint.pprint() or builtins.print() only when the output looks like debugging: the first argument starts with DEBUG, DBG, [DEBUG] or [DBG]; an f-string uses the {name=} debug form; or an argument is locals(), globals(), vars() or an object's __dict__.
  4. Any other print() is left alone. The finding is on the line of the call.

How to fix it

Delete the debugger call. If you need to see the value later, log it at debug level, where the log configuration decides whether it is written.

shop/checkout.py · Python · the fix, against the flagged file
"""Apply promotion codes at checkout.""" Added: import loggingAdded:  from shop.promotions import lookup_discount Added: logger = logging.getLogger(__name__) Added:  def apply_discount(order, code):    discount = lookup_discount(code)Removed:     breakpoint()Added:     logger.debug("discount %s for code %s", discount, code)    order.total = max(order.total - discount, 0)    return order

When it can be wrong

  • A developer tool or management command that is meant to open a debugger or print DEBUG: lines is reported.
  • A local function you named ic or breakpoint is reported as if it were the debugger.
  • It misses debugger calls written another way, such as import pdb as p; p.set_trace() or from pdb import set_trace.

Seeing a case that isn't listed here? Report the wrong result so the rule can be fixed. Don't paste company code: describe the shape of it.

How to silence it

  • Put the marker on the line of the call.

    Python
    breakpoint()  # skylos: ignore[SKY-L009] dev-only debug command
  • [tool.skylos] ignore = ["SKY-L009"] turns the rule off for the project.

From the Skylos rule handbook, Skylos 5.8.0 (commit 5b880b0). All rules.