Skip to main content

SKY-L029 · Logic and resilience

Unclear boolean argument

Low

The catalog gives no severity for this rule; the detector always reports LOW.

A function takes a True/False switch as an ordinary positional parameter, so callers can write send_invoice(invoice, True). At the call site nobody can tell what True means without opening the function. This is often called a boolean trap.

Languages
Python
Quality gate
counted toward the gate limits (full and diff scans). Only when listed. This is advice outside the default set: the report keeps it in JSON but does not list it, and the gate does not count it, unless you pass --all-advice or select the rule (--select SKY-L029). A finding based only on the signature, with no call that passes a bare True or False, is hidden for the same reason.
Finding type
advice
Wrong result? Report itA false positive, a missed case or a confusing message: it goes privately to the founder.

Why it matters

Readers guess, and reviewers miss swapped arguments: send(invoice, True, False) and send(invoice, False, True) look equally plausible. A switch added later in the wrong position still type-checks.

What Skylos flags

billing/invoices.py · PythonReported on line 6
"""Send monthly invoices.""" from billing.mail import send_mail  def send_invoice(invoice, include_pdf: bool = False):    attachments = [invoice.render_pdf()] if include_pdf else []    send_mail(invoice.customer.email, invoice.summary(), attachments)  def close_month(invoices):    for invoice in invoices:        send_invoice(invoice, True)

What Skylos leaves alone

billing/invoices.py · Python
"""Send monthly invoices."""  def sort_invoices(invoices, reverse=False):    return sorted(invoices, key=lambda invoice: invoice.due_date, reverse=reverse)  def newest_first(invoices):    return sort_invoices(invoices, True)

Why Skylos leaves it alone

reverse is one of a few switch names that are familiar from Python itself (sorted(..., reverse=True)), along with inplace, recursive, verbose, debug, force, dry_run and strict. Skylos accepts those on public functions.

How Skylos decides

  1. Runs with --quality on Python functions and methods. Test files, examples and build scripts are skipped, and so are dunder methods, self, cls and a property setter's value.
  2. A parameter is a candidate when it can be passed by position (it is not after *) and it is annotated bool (the builtin) or has a True or False default.
  3. Skips functions decorated @override or @overload, methods that override a base class in the same file, and functions passed around as values (callbacks must keep their signature).
  4. For a public function, reports every candidate except the familiar names inplace, reverse, recursive, verbose, debug, force, dry_run and strict. A private (_name) or nested function is reported only when a call in the same file passes a bare True or False in that position.
  5. Reports LOW on the parameter's line. When such calls exist, the message lists them.

How to fix it

Make the switch keyword-only by putting * before it, and name it at the call. Python then rejects send_invoice(invoice, True).

billing/invoices.py · Python · the fix, against the flagged file
"""Send monthly invoices.""" from billing.mail import send_mail  Removed: def send_invoice(invoice, include_pdf: bool = False):Added: def send_invoice(invoice, *, include_pdf: bool = False):    attachments = [invoice.render_pdf()] if include_pdf else []    send_mail(invoice.customer.email, invoice.summary(), attachments)  def close_month(invoices):    for invoice in invoices:Removed:         send_invoice(invoice, True)Added:         send_invoice(invoice, include_pdf=True)

When it can be wrong

  • A public library function whose positional signature is part of a published API is reported, even though changing it would break callers.
  • Calls in other files are not read, so a private helper called with bare literals from another module is missed.

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

    Python
    def send_invoice(invoice, include_pdf: bool = False):  # skylos: ignore[SKY-L029]
  • [tool.skylos] ignore = ["SKY-L029"] turns the rule off for the project.

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