diff --git a/src/sentry/issues/endpoints/group_event_details.py b/src/sentry/issues/endpoints/group_event_details.py index 6b2d4242d3b5..47c382c1d4a9 100644 --- a/src/sentry/issues/endpoints/group_event_details.py +++ b/src/sentry/issues/endpoints/group_event_details.py @@ -3,7 +3,7 @@ import functools import logging from collections.abc import Sequence -from typing import Any, NotRequired +from typing import Any, TypedDict, cast from django.contrib.auth.models import AnonymousUser from drf_spectacular.utils import OpenApiParameter, extend_schema @@ -127,9 +127,15 @@ def issue_search_query_to_conditions( return snql_conditions, resolved_legacy_conditions -class GroupEventDetailsFormattedResponse(GroupEventDetailsResponse): +class _GroupEventDetailsFormattedResponseOptional(TypedDict, total=False): # present only when ``?llmFormat`` is requested and the formatter option is on - formatted: NotRequired[FormattedResponse] + formatted: FormattedResponse + + +class GroupEventDetailsFormattedResponse( + GroupEventDetailsResponse, _GroupEventDetailsFormattedResponseOptional +): + pass @extend_schema(tags=["Events"]) @@ -292,4 +298,4 @@ def get( ) if data is None: return Response({"detail": "Failed to load event"}, status=500) - return Response(data) + return Response(cast(GroupEventDetailsFormattedResponse, data)) diff --git a/src/sentry/seer/autofix/types.py b/src/sentry/seer/autofix/types.py index 56945be90034..fccf6fcb8a9b 100644 --- a/src/sentry/seer/autofix/types.py +++ b/src/sentry/seer/autofix/types.py @@ -1,6 +1,6 @@ from __future__ import annotations -from typing import Annotated, Any, Literal, NotRequired, TypedDict, Union +from typing import Annotated, Any, Literal, TypedDict, Union from pydantic import BaseModel, Field @@ -38,9 +38,12 @@ class AutofixHandoffResponse(TypedDict): failures: list[dict[str, Any]] -class AutofixStateResponse(TypedDict): +class _AutofixStateResponseOptional(TypedDict, total=False): + # present only when ``?llmFormat`` is requested and the formatter option is on + formatted: FormattedResponse + + +class AutofixStateResponse(_AutofixStateResponseOptional): """Response type for the GET endpoint""" autofix: dict[str, Any] | None - # present only when ``?llmFormat`` is requested and the formatter option is on - formatted: NotRequired[FormattedResponse]