From 3290059483698a56abd6b022be6e173fc28457eb Mon Sep 17 00:00:00 2001 From: Greg Pstrucha <875316+gricha@users.noreply.github.com> Date: Sat, 31 Oct 2026 21:23:30 -0700 Subject: [PATCH] ref(typing): Let serialize() take a service account request.user can be a ServiceAccountPrincipal, and endpoints already pass it to serialize(), whose serializers handle it. The signature now says so. Type-only. --- src/sentry/api/serializers/base.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/sentry/api/serializers/base.py b/src/sentry/api/serializers/base.py index 96432586c89e..2537d3782c4e 100644 --- a/src/sentry/api/serializers/base.py +++ b/src/sentry/api/serializers/base.py @@ -2,7 +2,7 @@ import logging from collections.abc import Callable, Mapping, MutableMapping, Sequence -from typing import Any, Generic, TypeVar, overload +from typing import TYPE_CHECKING, Any, Generic, TypeAlias, TypeVar, overload from django.contrib.auth.models import AnonymousUser from sentry_sdk import traces @@ -10,6 +10,9 @@ from sentry.users.models.user import User from sentry.users.services.user.model import RpcUser +if TYPE_CHECKING: + from sentry.auth.principal import RequestPrincipal + logger = logging.getLogger(__name__) K = TypeVar("K") @@ -21,7 +24,7 @@ # is migrated. T = TypeVar("T", default=Any) -_User = User | RpcUser | AnonymousUser | None +_User: TypeAlias = "RequestPrincipal | None" registry: MutableMapping[Any, Any] = {}