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.
Problem
Silent
try/except: passpatterns 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
S110rule from flake8-bandit (already part of ruff) which detectstry-except-pass:Only
S110should be enabled, not the fullSgroup, because the other bandit rules produce false positives in our codebase:S101(assert detected) —assertis normal in pytestS102(exec used) — legitimate in the test runnerS603(subprocess without shell=False explicit) — noiseS607(partial path subprocess) — noiseAudit 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: passin the codebase:1.
lib/lis2mdl/device.py— unnecessary wrappersleep_ms()cannot raise — leftover from older code. Remove the try/except.2.
tests/report_plugin.py— intentional best-effort fallbackThe report plugin must never fail the test session if metadata collection fails. Keep with
# noqa: S110and a clarifying comment.Related
explicit-preview-rulesImplementation
Tracked in PR #383.