latent.lint.rules.lt020¶
LT020 — A catch-all handler around the call that publishes or gates a report.
Functions¶
lt020¶
A catch-all handler around the call that publishes or gates a report.
The two spellings differ in what the teardown sees, not in what the log
says. publish_report writing the report is what the teardown re-reads to
evaluate this flow's config/thresholds.yaml section, and
threshold_gate is that evaluation. Let either raise and the flow fails
with the reason attached. Swallow it and the run reports success having
gated nothing: the teardown finds no report, every threshold in the
lockfile is skipped, and the only trace is a warning line that reads like a
degraded-but-fine hiccup. That is LT018's outcome — gating silently off —
reached by a different route.
Narrower than ruff's BLE001 on purpose, and not a replacement for it.
BLE001 asks whether a handler is too broad anywhere; this asks only
where breadth converts a failed gate into a passing run, which is the case
a reviewer cannot recover by reading the log. It encodes the house rule
"never use catch-all logs to hide bugs". Best-effort emission is out of
scope by design — see :data:_GATE_EMITTERS.
Only the protected body is searched — an emitter in else: or
finally: is not covered by the handler, so it is not this defect. A
handler that raises is silent (:func:_reraises), and so is one that names
its exception: except ValueError around a gate whose input may be
malformed is a decision, not a swallow. A handler that ends the process
without a raise reads as swallowing here and wants a waiver.