Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 10 additions & 4 deletions src/sentry/issues/endpoints/group_event_details.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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"])
Expand Down Expand Up @@ -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))
11 changes: 7 additions & 4 deletions src/sentry/seer/autofix/types.py
Original file line number Diff line number Diff line change
@@ -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

Expand Down Expand Up @@ -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]
Loading