Repository navigation
Conversation
anth-volk
added this pull request to stack #755
October 14, 2026 13:54
anth-volk
force-pushed
the
ruff-structure-imports
branch
2 times, most recently
from
October 14, 2026 14:47
2a7ddcc to
30b23b7
Compare
2 tasks done
anth-volk
force-pushed
the
ruff-structure-imports
branch
4 times, most recently
from
October 14, 2026 20:04
b013982 to
548762d
Compare
anth-volk
force-pushed
the
ruff-structure-imports
branch
2 times, most recently
from
October 14, 2026 21:43
20049c1 to
68eea13
Compare
Tests deliberately reach into private members, pytest test directories aren't packages, and tests often import inside a test after patching the environment. Application code still gets every rule. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
FastAPI takes the response model from the return annotation when response_model is omitted, so the generated OpenAPI documents are unchanged. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
- Alias the shared exit registry as app_exit where it is imported, and keep the policyengine_fastapi.exit.exit name that projects import. - Use snake_case for the OpenTelemetry provider and log-handler locals. - Add the Error suffix to exceptions that never leave their project: BackendUnavailableError, BackendTimeoutError, TemporaryStage12UnsupportedRequestError and ParityMismatchError. TemporaryStage12DispatchFailed keeps its name, which the entry app logs as error_type. - Keep the camelCase budget-window fields, which are published JSON, the explicit re-exports in stage12_execution, and the two deliberate private accesses, each with a reason. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Declare the script directories (.github/scripts, scripts and the executor's scripts) and the rules proof fixtures as namespace packages in ruff.toml. Ruff's full output, with every rule selected, is otherwise unchanged by the setting. The executor's src/modal/utils scripts keep an inline suppression instead: declaring that directory, or adding an __init__.py, makes ruff treat it as part of a first-party "modal" package and regroup its Modal SDK imports. An __init__.py would also change the src.modal source baked into the Modal images. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…(ruff PLC0415) Each deferred import keeps an inline reason: the GCP exporters, logging instrumentation and metadata probe load only when used, and only the bundle-versions command runs where policyengine is installed. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
app.py already imports stage12_backend at module level for its exception types, so binding Stage12ComparisonBackend there too loads nothing new. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Bind SPMSelection in endpoints.py's existing policyengine_simulation_contract.spm import. Keep the Modal function body's imports, which build the web app in its container, and the smoke app's in-image imports, each with a reason. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Move only imports that load nothing new and that no test patches: pathlib and importlib, the policyengine_simulation_contract helpers, names from a module the file already imports at the top, and RegionGroupStrategy, which policyengine.core already loads. Every other deferred import keeps an inline reason: Modal function bodies and the image-build and smoke functions, lazily loaded policyengine models and heavy libraries, call-time resolution that the tests' patch seams rely on, and import cycles in the runtime. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Split long messages and the GCP log format with implicit string concatenation, so every string is unchanged, and rewrap two docstrings that no published schema uses. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Bind the long generated endpoint functions to shorter local names before calling them. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Split long strings with implicit concatenation, so every value is unchanged. The fake curl and gcloud scripts keep their single-line printf output with a suppression on the string. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Split long messages and test strings with implicit concatenation, so every value is unchanged, and shorten docstrings that no published schema uses. The fake gh script keeps its single-line JSON output with a suppression on the string. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Split the Modal app's FastAPI description with implicit concatenation, so the published text is unchanged, and shorten four test names. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Select A, E, FAST, INP, N, PLC and SLF. Every finding outside the shared scripts/rules tool is fixed or carries an inline reason; the rules tool's findings are fixed upstream and synced separately. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
sim.quality.ruff-lint now lists A, E, FAST, INP, N, PLC and SLF. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The shared scripts/rules tool takes the Public API's group 7 fixes: wrapped long lines, BaseUnavailableError, and assert_violation in its tests. The rendered rules page picks up the tool's new hash. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
#743 and #744 landed on main after this stack branched. Group 7, which this PR enables, flags their new code; each fix follows this PR's conventions: - E501: wrap the long strings in their routing, sentinel, gateway and test code; every message and expected value reads the same. - N818: RoutingConflict never leaves the executor, so it becomes RoutingConflictError, as this PR renames the other in-project errors. - INP001: the sentinel script in src/modal/utils keeps the inline reason the other scripts there carry. - PLC0415: the sentinel's deferred contract and runtime imports and the package updater's optional receipt import keep inline reasons. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
#789 landed on main after this stack branched. E501, which this PR enables, flags the signature line of its lost-commit coordinator test, whose name cannot be wrapped; the line keeps a reasoned suppression rather than a shorter, vaguer name. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
anth-volk
force-pushed
the
ruff-structure-imports
branch
from
October 14, 2026 21:52
68eea13 to
51e611a
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 #798
Same-Repository Draft PR Check
PolicyEngine/policyengine-sim-api, not a personal fork.Summary
Phase 1 step 1.8, group 7: structure and imports. Stacked on #785.
**/tests/**and**/authenticated_tests/**now also ignoreSLF001,INP001andPLC0415, alongsideS101,D1,ANNandPLR2004. Tests deliberately reach into private members, pytest test directories aren't packages, and tests often import inside a test after patching the environment. Application code still gets every rule. Both test-exemption rules in the registry are updated to match.ruff.tomlgainsA,E,FAST,INP,N,PLCandSLF. All 339 findings left after the exemption are fixed or kept with an inline reason..github/scripts,scripts, the executor'sscriptsandrules/fixturesaren't packages, so they're declared in ruff's top-levelnamespace-packagessetting. Compared with the fullruff checkoutput before the change, nothing else differs. The executor'ssrc/modal/utilsscripts keep an inline suppression instead: declaring that directory made ruff treatimport modal(the Modal SDK) as first-party, and an__init__.pywould change the source copied into the Modal images.BackendUnavailableError,BackendTimeoutErrorandTemporaryStage12UnsupportedRequestError, and the executor'sParityMismatchError. Each is caught by name and never logged or stored by class name.TemporaryStage12DispatchFailed, because the entry app logs its class name aserror_type.gateway_models.pykeep their names.exitimport aliased asapp_exit, and four gateway test names shortened for line length.exitobject projects import, and two private accesses with no public equivalent.response_modelarguments that repeat the return type are dropped. The gateway golden OpenAPI is unchanged, and the entry, executor and gateway OpenAPI dumps are identical before and after.printfJSON can't be split without changing the script.src/modal/app.pygains no__future__import. CI's image smoke will run when this PR reaches the bottom of the stack.sim.quality.ruff-lintnow lists the seven families. The shared rules tool is synced from the Public API's group 7 (Enable ruff structure and import rules (INP, PLC, SLF, N, A, FAST, E) policyengine-api#3920), so it's byte-identical again (tool sha256f7e9b6462761).Testing
All seven projects' test suites pass, with the same counts as the base:
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-test project's conftest change was checked by parsing only; its tests need live services.
CI/CD: no workflow changed, and no environment variable was added or rewired.
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