fix(server): annotate SQLAlchemy result rows for 2.1 type inference [SAO-17580] - #272
Merged
Merged
Conversation
…SAO-17580] SQLAlchemy 2.1.0 no longer lets mypy infer the element type through `result.scalars().all()`, so `make typecheck` fails on `main` and on every open PR with var-annotated. The repository lock pins 2.0.51, which still infers it, so the error surfaces only in CI where dependencies resolve fresh. Main's own run at bd7d91f installs mypy 2.3.1 and sqlalchemy 2.1.0 and reports the error, which is why re-running a job does not clear it. Annotate all four call sites that share the pattern. CI reports only the first, so fixing them one at a time would surface the next on the following run. The annotations hold under 2.0.51 and 2.1.0 alike, so the result does not depend on which version CI resolves. Raising the SQLAlchemy floor or regenerating the lock is left alone. That is a wider dependency decision, and these annotations are correct either way.
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
josjeon
enabled auto-merge (squash)
September 28, 2026 19:45
namrataghadi-galileo
approved these changes
Sep 28, 2026
7 of 8 tasks
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.
Summary
make typecheckcurrently fails onmainand on every open PR. This annotates the four call sites that SQLAlchemy 2.1.0 broke, unblocking merges.The failure belongs to no branch's changes.
What happened
SQLAlchemy 2.1.0 no longer lets mypy infer the element type through
result.scalars().all():The repository lock pins 2.0.51, which still infers it, so the error appears only in CI, where dependencies resolve fresh. Main's own run at
bd7d91finstalls both and reports the error in the same log:Evidence this is not branch-specific
mainmainfix/sao-17418-runtime-token-authfix/sao-17418-runtime-token-authSQLAlchemy 2.1.0 was released between those dates, and the flagged file is not in the diff of either affected PR. Re-running the job does not clear it: CI resolves 2.1.0 again each time, so the failure is deterministic rather than flaky.
What changed
Four sites share the pattern. CI reports only the first, so fixing them one at a time would surface the next on the following run.
services/control_bindings.py:282rows: list[ControlBinding]services/controls.py:306versions: list[ControlVersion]services/controls.py:512controls: list[Control]endpoints/agents.py:463agents: Sequence[Agent]agents.pykeepsSequencerather thanlistbecause that call site does not wrap the result inlist()and only reads and slices it.SequenceandAgentwere already imported there.Scope
pyproject.tomlor regenerating the lock. That is a wider dependency decision, and these annotations are correct under either version.Risk and Rollout
Testing
mypy server/srcclean under the locked versions: 51 source files, no issues.ruff check server/srcclean.mainis cited above instead.Checklist
AI Tool Assistance Usage Statement