Skip to content

Commit a118c34

Browse files
anth-volkclaude
andauthored
Raise TypeError for a non-object .py bundle manifest
Nothing catches the error from _load_policyengine_bundle, which runs at import, and only a unit test pinned RuntimeError, so the type check now raises TypeError and needs no TRY004 suppression. The changelog fragment also describes the contextlib.suppress blocks and the narrowed catches. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
1 parent a77d0bc commit a118c34

3 files changed

Lines changed: 3 additions & 3 deletions

File tree

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
Enabled ruff's exception rules (TRY, EM, BLE): exception messages are built before the raise, raises inside try blocks moved into helpers, the v1 services raise typed exceptions, and every deliberate catch-all carries a reasoned suppression; error responses and message text are unchanged.
1+
Enabled ruff's exception rules (TRY, EM, BLE): exception messages are built before the raise, raises inside try blocks moved into helpers, the v1 services raise typed exceptions, best-effort telemetry and logging calls use a commented contextlib.suppress block, and every other deliberate catch-all carries a reasoned suppression. Period parsing and the simulation health probe now catch only the errors they expect, and a non-object .py bundle manifest raises TypeError. Error responses and message text are unchanged, except that a non-HTTP failure in the simulation health probe now gets the route's existing 503 for a client failure.

‎policyengine_api/constants.py‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ def _load_policyengine_bundle() -> dict | None:
6969
raise RuntimeError(msg) from exc
7070
if not isinstance(manifest, dict):
7171
msg = "PolicyEngine .py bundle manifest must be a JSON object."
72-
raise RuntimeError(msg) # noqa: TRY004 # tests expect RuntimeError for a non-object manifest
72+
raise TypeError(msg)
7373
return manifest
7474

7575

‎tests/unit/test_constants.py‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -228,7 +228,7 @@ def test__load_policyengine_bundle_rejects_non_object_manifest(
228228
lambda: manifest_path,
229229
)
230230

231-
with pytest.raises(RuntimeError, match="must be a JSON object"):
231+
with pytest.raises(TypeError, match="must be a JSON object"):
232232
_load_policyengine_bundle()
233233

234234
def test__uses_policyengine_bundle_versions_for_us_uk_and_core(self):

0 commit comments

Comments
 (0)