Skip to content

tooling: Enable ruff S110 to detect try-except-pass. #384

@nedseb

Description

@nedseb

Problem

Silent try/except: pass patterns hide errors and make debugging harder. The github-code-quality bot detected such patterns in PR #382 (deploy_usb.py), but our ruff configuration did not catch them automatically — meaning future occurrences would also slip through review.

Proposed fix

Enable the S110 rule from flake8-bandit (already part of ruff) which detects try-except-pass:

"S110",   # flake8-bandit: try-except-pass (no silent exception suppression)

Only S110 should be enabled, not the full S group, because the other bandit rules produce false positives in our codebase:

  • S101 (assert detected) — assert is normal in pytest
  • S102 (exec used) — legitimate in the test runner
  • S603 (subprocess without shell=False explicit) — noise
  • S607 (partial path subprocess) — noise

Audit results: 5 distinct S rules trigger 30 violations total, but only 4 of them (S110) are actually problematic.

Existing violations to fix

Audit found 2 try/except: pass in the codebase:

1. lib/lis2mdl/device.py — unnecessary wrapper

try:
    sleep_ms(10)
except Exception:
    pass

sleep_ms() cannot raise — leftover from older code. Remove the try/except.

2. tests/report_plugin.py — intentional best-effort fallback

The report plugin must never fail the test session if metadata collection fails. Keep with # noqa: S110 and a clarifying comment.

Related

Implementation

Tracked in PR #383.

Metadata

Metadata

Assignees

Labels

releasedtoolingDeveloper tooling, build system, hooks

Type

No type
No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions