From 432d1e1a7ffb220505b9a5983fcefac61af769d3 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci-lite[bot]" <117423508+pre-commit-ci-lite[bot]@users.noreply.github.com> Date: Sat, 25 Apr 2026 03:42:17 +0000 Subject: [PATCH] =?UTF-8?q?=F0=9F=8E=A8=20Auto=20format?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- fastapi/sse.py | 5 ++--- tests/test_sse.py | 4 +--- 2 files changed, 3 insertions(+), 6 deletions(-) diff --git a/fastapi/sse.py b/fastapi/sse.py index 276efa4cd0..1dcb3be765 100644 --- a/fastapi/sse.py +++ b/fastapi/sse.py @@ -7,7 +7,7 @@ from annotated_doc import Doc from pydantic import AfterValidator, BaseModel, Field, model_validator from starlette.background import BackgroundTask from starlette.responses import StreamingResponse -from starlette.types import Receive, Send, Scope +from starlette.types import Receive, Scope, Send # Canonical SSE event schema matching the OpenAPI 3.2 spec # (Section 4.14.4 "Special Considerations for Server-Sent Events") @@ -113,7 +113,6 @@ class EventSourceResponse(StreamingResponse): Each item is expected to be a :class:`ServerSentEvent` (encoded automatically) or already-raw bytes (passed through). """ - from fastapi.sse import ServerSentEvent, format_sse_event if hasattr(content, "__aiter__"): async for item in content: @@ -386,7 +385,7 @@ class ServerSentEvent(BaseModel): ] = None @model_validator(mode="after") - def _check_data_exclusive(self) -> "ServerSentEvent": + def _check_data_exclusive(self) -> ServerSentEvent: if self.data is not None and self.raw_data is not None: raise ValueError( "Cannot set both 'data' and 'raw_data' on the same " diff --git a/tests/test_sse.py b/tests/test_sse.py index e17b5b823e..14c91ef7a8 100644 --- a/tests/test_sse.py +++ b/tests/test_sse.py @@ -355,9 +355,7 @@ def test_encode_comment(): def test_encode_raw(): """encode_raw() places raw data without JSON encoding.""" - result = EventSourceResponse.encode_raw( - raw_data="