Repository navigation
Conversation
anth-volk
added this pull request to stack #755
October 13, 2026 17:01
anth-volk
force-pushed
the
ruff-exceptions
branch
from
October 13, 2026 17:14
a8c8dba to
a542fe0
Compare
Draft
2 tasks done
anth-volk
force-pushed
the
ruff-exceptions
branch
2 times, most recently
from
October 14, 2026 14:47
860de6c to
6240467
Compare
anth-volk
force-pushed
the
ruff-exceptions
branch
2 times, most recently
from
October 14, 2026 17:56
0fafb0a to
89401c2
Compare
anth-volk
force-pushed
the
ruff-exceptions
branch
from
October 14, 2026 19:46
89401c2 to
d1f8d40
Compare
Exception messages move into a msg variable before the raise (EM), with the text unchanged. The JWT decoder re-raises with a bare raise (TRY201). Its two JWKS lookup error logs stay traceback-free under a TRY400 noqa, because callers control the token and a traceback per bad token would let them flood the logs. The token decode and the GCP project-id probe keep except Exception under a BLE001 noqa: any decode failure must become a 403, and any probe failure falls back to GOOGLE_CLOUD_PROJECT. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Exception messages move into a msg variable before the raise (EM), with the text unchanged; Pydantic validators keep raising ValueError, so callers still get the same ValidationError. resolve_spm_selection and validate_spm_result move their try bodies into private helpers so no raise sits inside the try (TRY301, TRY300); the same ValueErrors still become the same SPMInputError, chained from the original. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…rary Exception messages move into a msg variable before the raise (EM), with the text unchanged. log_and_redact_exception's fallback log calls logger.exception with the same explicit exc_info, so its output is unchanged (TRY400). Its telemetry catch-all keeps except Exception under a BLE001 noqa, because the helper must never raise. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Exception messages move into a msg variable before the raise, with the text unchanged. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Exception messages move into a msg variable before the raise (EM), with the text unchanged. forward() returns the proxied response from an else block (TRY300). The four Stage 12 diagnostic error logs stay traceback-free under a TRY400 noqa: three record only the error type, so a traceback could carry request or calculation data, and the dispatch timeout is fully described by its timeout. The Stage 12 context capture keeps its telemetry catch-all under a BLE001 noqa. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Exception messages move into a msg variable before the raise (EM), with the text unchanged. The auth misconfiguration log keeps its message and gains a traceback through exc_info=True (TRY400). _runtime keeps RuntimeError and _resolve_policyengine_route keeps ValueError under a TRY004 noqa, because handlers and callers depend on those types. The job-status and budget-window handlers keep their catch-alls under a BLE001 noqa: call.get re-raises whatever the worker raised, and every failure must become a failed-job response or fall back to the seed state. The auth-bypass event keeps its catch-all too. The golden OpenAPI spec is unchanged. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Exception messages move into a msg variable before the raise (EM), with the text unchanged. Raises inside try bodies move into private helpers (_parse_policy_period_dates, _certified_us_spm_capability, _require_artifact_digest, _require_local_authority_column), so the same exceptions reach the same handlers (TRY301, TRY300); dump_package_version narrows its try to the file read. qualify_stage12_parity, a local operator CLI that nothing calls or catches, now raises TypeError for a JSON value that is not an object. The other TRY004 sites keep their types under a noqa: they cross a Modal boundary, are documented or asserted by tests, or are recorded by type name in telemetry and Stage 12 error summaries. The Stage 12 comparison failure log stays traceback-free under a TRY400 noqa. Worker, cleanup and telemetry catch-alls keep except Exception under a BLE001 noqa. The Modal images copy src/modal and policyengine_simulation_executor, so their layers change like any source edit; src/modal/app.py gains no future import. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Exception messages move into a msg variable before the raise, with the text unchanged. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Select flake8-blind-except (BLE), flake8-errmsg (EM) and tryceratops (TRY). The preceding commits fix every finding; deliberate catch-alls, kept exception types and traceback-free error logs carry an inline noqa with the reason. Tests get no exemption. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Enabling BLE activated suppressions that were written before the rule was on. Seven had no reason, or kept it only in a comment above; they now carry it inline, and the "- reason" ones use the " # reason" form. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The EM fix moves an exception's first literal argument into a variable called msg. SPMInputError's first argument is an error code, followed by the message, so those 20 variables are renamed error_code. The gateway file also moves its BLE001 suppression reason to the " # reason" form. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
sim.quality.ruff-lint now lists the group 5 families, and the rendered rules page and AGENTS.md Rules block are regenerated. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
ParityMismatch takes a code and a schema path, not a message, so the 26 variables the EM fix named msg are renamed error_code. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The colon after "(TRY, EM, BLE)" made YAML read the item as a mapping rather than a string. The line also said error types were unchanged, but two type checks in qualify_stage12_parity.py now raise TypeError. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
#743 and #744 landed on main after this stack branched. EM and TRY003, which this PR enables, flag 34 raises in their sentinel, routing and package-update code that pass a literal message. Each message now moves into a msg variable before the raise, with the text unchanged. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
#789 landed on main after this stack branched. EM and TRY003, which this PR enables, flag five raises in its new Stage 12 tests that pass a literal message; each message now moves into a msg variable first. TRY301 flags the raise inside the pooling test's transaction, which moves into a small helper so the same RuntimeError still ends that transaction. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
anth-volk
force-pushed
the
ruff-exceptions
branch
from
October 14, 2026 20:04
d1f8d40 to
5799eea
Compare
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #782
Same-Repository Draft PR Check
PolicyEngine/policyengine-sim-api, not a personal fork.Summary
Phase 1 step 1.8, group 5: exceptions and messages. Stacked on #779.
ruff.tomlgainsTRY,EMandBLE. All 1,029 findings at the base are fixed, one commit per project: executor 522, contract 226, Stage 12 persistence 102, entry 70, gateway 52, repo scripts 28, integration tests 12, fastapi 11, observability 6.raise(520 places). A script put every message back inline: all 74 files reproduce the base's syntax tree exactly, so the message text is unchanged. No tracked Python file usedmsgbefore.SPMInputErrororParityMismatchis an error code, the hoisted variable is namederror_code, notmsg(46 places).tryblocks (TRY301 9, TRY300 4): each raise moves into a small private helper, or thereturnmoves into anelse:. Each handler still receives the same exceptions: for example, contractspm.pystill wraps the helpers'ValueErrorin the sameSPMInputError.src/modal/utils/qualify_stage12_parity.pyraisesTypeErrorfor its two type checks. It's an operator command-line tool that nothing calls or catches.except Exceptioncatches (BLE001 13): none narrowed, all kept with an inline reason. Telemetry must never fail a request or a Modal call; a worker failure must become a failed-job or failed-batch response; and a token decode failure must become a 403, never a 500. Ruff accepts only a traceback-logging call instead, which would raise log levels.noqa: BLE001comments, inert until now, had no reason or used the- reasonstyle. They now carry a reason in the standard# reasonform.logger.exceptionand still logs the original exception's traceback.timeout_secondsfield.raise errbecomes a bareraisein the JWT decoder._image_setup.py:fetch_artifactsis a build step and only its messages moved, but expect that layer and the snapshot layer after it to rebuild on the next deploy.sim.quality.ruff-lintnow listsBLE,EMandTRY. The shared rules tool needed no changes and is still byte-identical with the Public API (tool sha256db83d5ad2aa4). The Public API's group 5 is Enable ruff exception rules (TRY, EM, BLE) policyengine-api#3913.Testing
All seven projects' test suites pass at this branch's tip, with the same counts as the base:
The executor count includes the 10 stacked-PR gate tests from Make CI enforcement trustworthy before the rules registry #754 and Add a rules registry that makes every enforced and unenforced rule visible #752.
The gateway golden OpenAPI test passes, and the golden file is unchanged.
ruff check(0.15.22) is clean repo-wide, andruff format --checkis unchanged.The rules guard, the
ci-scriptsguard and the rules tool unittest pass.The integration tests and
authenticated_testsneed live services, so they were only byte-compiled.CI: this PR is above the bottom of its stack, so it runs only
CI complete, which fails and says why (step 0.7, Make CI enforcement trustworthy before the rules registry #754). Its full run starts once the PRs below it merge.🤖 Generated with Claude Code