Repository navigation
feat(python): add an opinionated swallowed-exception guide - #70
LiinaSuoniemi wants to merge 1 commit into
Conversation
Adds a python-owned guide for swallowed-exception (ruff BLE001) so a python config coaches the smell directly instead of falling through to generic or, with no generic, to uncoached. Coaches the judgment (name the exception, narrow the catch, make the decision visible) and treats log-and-return as a valid option, not automatically a swallow. Inlines its line listing rather than the generic include so a python-only config cannot crash on a missing generic. Follows the deep-nesting.md shape. Adds a habit-mapper spec case that renders it for a python-only finding.
|
Thanks for this, Liina. Two small suggestions before it lands:
One ordering note: this overlaps with #68, which uses |
|
Merged into
Landed after #68 and #69, all green. Thank you for the guide — the coaching stance and the "3am" test are genuinely good, and they're in |
What this adds
An opinionated Python guide for
swallowed-exception(ruffBLE001), so a python config coaches the smell directly. Today a["python"]config has no guide for it and falls through to the generic default, or to uncoached whengenericis not present.The coaching stance
It coaches the judgment instead of enforcing a blanket rule. Name the specific exception, narrow the catch to it, then make the decision visible. Logging and returning a default is treated as a real option, not automatically a swallow. The check it gives is behavioural: "if this fires at 3am, will anyone know it happened, and why." A swallow is the blind version, a wide catch, nothing named, nothing logged, no trace.
Design notes
{% include "includes/line_level_issues.md" %}. That include lives in the generic plugin, so a["python"]config with no generic would crash on it. Inlining keeps the guide self-contained and safe for python-only.deep-nesting.md: a prose diagnosis, the line listing, a numbered procedure with bold lead-ins, then an anti-gaming closer.Tests
One new case in
habit-mapper.spec.mdrenders the guide for a python-only swallowed-exception finding (suggested, exits 0). Full python suite green (+1 test, no regressions vs base). The Node and PHP specs that fail in CI are pre-existing and unrelated (the workflow installs Python only).Note on PR #68
This makes
swallowed-exceptionguided for a python-only config. My other open PR (#68) usesswallowed-exceptionas its example of an unguided smell, in the case "A python-only config coaches an unguided smell via the core uncoached guide." If both land, that test should switch to another still-unguided python smell such astoo-many-parameters. Flagging so the merge order is clear.Style
Kept the prose tight and dash-free for clarity, happy to match the house em-dash style if you would rather.