Repository navigation
Conversation
anth-volk
added this pull request to stack #755
October 13, 2026 12:35
2 tasks done
anth-volk
force-pushed
the
ruff-annotations
branch
from
October 13, 2026 16:56
d1b005d to
717c85e
Compare
Add the missing parameter and return annotations. AppExit forwards its callback arguments as object rather than Any, the JWT decoder's private validator returns the same dict type its caller declares, and the metrics middleware types call_next as Starlette's RequestResponseEndpoint. Ping endpoints already pass response_model explicitly, so their new return annotations do not change the generated responses. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Type the SPM resolution and validation entry points, the gateway request pre-validators (object in, object out) and the Modal Dict store helpers. The three wrap model serializers in spm.py stay unannotated with a reasoned noqa: Pydantic turns a serializer's return annotation into the model's serialization JSON schema, which would rewrite the OpenAPI spec. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…f ANN Replace Any with object for values that are only inspected or passed through, and type the persistence row helpers with SQLAlchemy's RowMapping, Table and ColumnElement (imported for type checking only). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Every annotated route passes response_model explicitly, so FastAPI keeps using it and the OpenAPI golden file is unchanged. _bundle_payload keeps Any for **dump_kwargs, forwarded unchanged to BaseModel.model_dump, with a reasoned noqa. Test fixtures outside tests/ are annotated too. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Type the runtime, output builders, Modal entrypoints, scripts and the test fixtures that live outside tests/. PolicyEngine, Google Cloud Storage and observability types are imported for type checking only, country modules are ModuleType, and duck-typed analysis values that tests replace with SimpleNamespace are object. _try_compute_output uses a ParamSpec so its arguments are checked against the wrapped function. The in-repo src/modal package shadows the Modal library here, so Modal types stay quoted or behind TYPE_CHECKING. _image_setup.py may not import anything at module level, so it uses a local TYPE_CHECKING flag. The RemoteFunction protocol keeps Any (with a reasoned noqa) because it mirrors modal.Function.remote and spawn, whose payloads vary per function. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Select ANN. Tests are exempt, alongside the docstring, magic-number and assert rules a later group will enable. scripts/rules findings are left for the next sync from policyengine-api. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
_json_from_stdin returns object (every caller narrows it), and the proof fixtures annotate their SQLAlchemy connection and table parameters. The schema-authority proof reads the fixtures as text, so it is unaffected. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
sim.quality.ruff-lint now includes ANN, and the **/tests/** per-file ignore list (S101, D1, ANN, PLR2004) is registered as sim.quality.tests-ruff-exemptions. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
anth-volk
force-pushed
the
ruff-annotations
branch
from
October 13, 2026 17:14
717c85e to
7dc400d
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 #776
Same-Repository Draft PR Check
PolicyEngine/policyengine-sim-api, not a personal fork.Summary
Phase 1 step 1.8, group 3: annotations. Stacked on #773.
ruff.tomlgainsANN, and every function outside tests is now annotated, one commit per project. Findings fixed: fastapi 35, contract 36, observability 4, persistence 6, entry 11, gateway 40, executor 230, plus a CI script and the proof fixtures.Any: replaced by real types, such as policyengineSimulation/Dataset/Policy/Region,ModuleType,storage.Clientand SQLAlchemyRowMapping/Table.objectis used for opaque values.**dump_kwargsis forwarded tomodel_dump;remote/spawnprotocol's results vary by function;noqa: ANN201, because annotating them changes the OpenAPI schema.src/modal/app.pygets no__future__import, because Modal records function signatures._image_setup.pykeeps its no-imports constraint.fetch_artifactswill rebuild that image layer once on the next deploy.main: Count households once: sum the weight column unweighted #767 added_count_output_entitiesnext to_sum_output_variableinsimulation_output_common.py, which conflicted with this PR. Both now takesimulation: Simulation.**/tests/**ignoresS101,D1,ANNandPLR2004, registered assim.quality.tests-ruff-exemptions.Testing
All seven projects' test suites match their baselines:
ruff checkis clean, andsrcformatting is unchanged.Pyright: it isn't run in CI, and none of the new errors comes from a wrong annotation.
span()context, which is typed as possibly swallowing exceptions.ensure()guarantees, pandas.sum()typing, and narrowing afterhasattr.🤖 Generated with Claude Code