Skip to content

ref(typing): Let serialize() take a service account - #129412

Draft
gricha wants to merge 1 commit into
ref/principal-helper-examplesfrom
ref/typing-serialize-principal
Draft

gricha wants to merge 1 commit into
ref/principal-helper-examplesfrom
ref/typing-serialize-principal

Conversation

@gricha

@gricha gricha commented Oct 31, 2026 •

Copy link
Copy Markdown
Member

Endpoints pass request.user to serialize(), and it can be a service account. Serializers already handle that at runtime, but the signature said User | RpcUser | AnonymousUser | None. It now takes a RequestPrincipal | None.

Type-only. Without it, #129402's mypy check would flag 160 files that only pass request.user to serialize().

Serializer methods (get_attrs/serialize) still declare the old user type; serialize() hands them an untyped serializer, so nothing here hides an error. Widening the serializer tree itself is a later step.

@gricha
gricha added this pull request to stack #129364 October 31, 2026 01:30
@github-actions github-actions Bot added the Scope: Backend Automatically applied to PRs that change backend components label Oct 31, 2026
request.user can be a ServiceAccountPrincipal, and endpoints already pass it to serialize(), whose serializers handle it. The signature now says so. Type-only.
@gricha
gricha removed this pull request from stack #129364 November 1, 2026 04:24
@gricha
gricha changed the base branch from ref/mypy-request-user-principal to ref/principal-helper-examples November 1, 2026 04:24
@gricha
gricha force-pushed the ref/typing-serialize-principal branch from f00e055 to 6f0e130 Compare November 1, 2026 04:24
@gricha
gricha added this pull request to stack #129440 November 1, 2026 04:24

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Scope: Backend Automatically applied to PRs that change backend components

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant