Re-enable ruff BLE (blind-except) rule and fix all violations
Summary
- Removes
BLEfrom the global ruff ignore list inpyproject.tomland resolves all 78 violations it surfaces (the card's original ~32 estimate was from a February analysis; the count grew — reconciled and re-measured as part of this work, seedev/specs/002-ruff-ble-reenable/data-model.md). - 8 sites (test/tooling code) got genuine exception narrowing to the specific type(s) the guarded code can raise.
- 70 sites kept
except Exceptionwith a targeted# noqa: BLE001plus a one-line justification comment, where a broad catch is a deliberate design choice (best-effort telemetry, top-level migration/error-collection loops, etc.) — annotation-only, no logic or control-flow changes. - Full spec-kit trail in
dev/specs/002-ruff-ble-reenable/(spec, plan, critique, tasks, alignment check, final implementation report).
Reviewer note: 24 of the changed files fall in paths this repo normally reviews extra carefully — 19 under backend/infrahub/core/migrations/graph/, 4 auth modules (api/auth.py, api/oauth2.py, api/oidc.py, auth/auth.py), and core/schema/update_coordinator.py. Every touch in those files is the identical mechanical pattern (justification comment + # noqa: BLE001 above an existing except Exception:) — confirmed by an explicit diff-audit task (SC-007) and independently re-verified by the review pass below. No behavior change. Worth a close look given the sensitivity of those paths regardless.
Source: Engineering Inbox INBOX-19, from Patrick's pyproject suppression-analysis thread (ranked BLE re-enable priority #1 — direct bug risk, small bounded count, lowest effort).
Test plan
-
ruff check --select=BLE .— 0 violations repo-wide -
uv run invoke backend.lint(ruff + ty + mypy) — clean -
uv run invoke backend.test-unit— 1846 passed - Two previously-non-collecting component tests (
test_process_idempotency.py,test_uniqueness_propagation.py) confirmed passing — 12 passed (the earlier "no tests collected" signal was a CLI-proxy summarizer false negative, not a real defect) - Suppression audit — 70/70 sites carry a justification comment; enforcement canary (reintroducing one unjustified BLE001) confirmed the rule now fails as expected, then reverted
-
uv lock --check,schema.validate-graphqlschema,schema.validate-jsonschema,backend.validate-generated,docs.validate— all clean, zero diff - Two independent review passes (error-handling, simplification) across the full diff — no CRITICAL/HIGH findings; one pre-existing/accepted design tradeoff and a few cosmetic nits noted in the implementation report, none blocking
🤖 Generated with Claude Code
Summary by cubic
Re-enabled the ruff BLE (blind-except) rule and fixed all 78 violations by narrowing where safe and documenting intentional broad handlers. Updated two suppressions to clearly note rollback-in-transaction and retry-bypass caveats. Aligns with INBOX-19.
- Refactors
- Removed BLE from
pyproject.tomlignore; repo passesruffwith the rule active. - Narrowed 8 sites to specific exceptions:
SchemaNotFoundError(component tests),httpx.HTTPError(git integration fixtures),packaging.InvalidVersion(tasks/release.py). - Kept 70 deliberate broad handlers with
# noqa: BLE001and a one-line justification; revised comments inm066_consolidate_duplicate_number_pools.pyandcore/validators/tasks.pyto state the rollback and retry caveats; no behavior change. - Added changelog fragment and spec-kit docs under
dev/specs/002-ruff-ble-reenable/. - Lint and tests remain green (
invoke backend.lintand existing test suites).
- Removed BLE from