Skip to content

Commit dac39e8

Browse files
benmosherclaude
andcommitted
🐛 Fix mypy [type-arg] error by giving Data TypeVar a default of Any
Bare `ServerSentEvent` (without a type parameter) now silently resolves to `ServerSentEvent[Any]`, so existing code and the `_check_data_exclusive` return annotation require no changes and pass mypy without `[type-arg]` errors. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
1 parent 56cce71 commit dac39e8

1 file changed

Lines changed: 4 additions & 2 deletions

File tree

fastapi/sse.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,12 @@
1-
from typing import Annotated, Any, Generic, TypeVar
1+
from typing import Annotated, Any, Generic
2+
3+
from typing_extensions import TypeVar
24

35
from annotated_doc import Doc
46
from pydantic import AfterValidator, BaseModel, ConfigDict, Field, model_validator
57
from starlette.responses import StreamingResponse
68

7-
Data = TypeVar("Data")
9+
Data = TypeVar("Data", default=Any)
810
"""Type variable for the `data` payload of a `ServerSentEvent`.
911
1012
Use ``ServerSentEvent[MyModel]`` to indicate that every event in the

0 commit comments

Comments
 (0)