Skip to content

Commit 0b4317a

Browse files
authored
Merge pull request #82 from sysid/fix/typing
fix: typing
2 parents 7c7779e + a16ff9c commit 0b4317a

File tree

3 files changed

+64
-2
lines changed

3 files changed

+64
-2
lines changed

pdm.lock

Lines changed: 56 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

pyproject.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,7 @@ dev = [
8585
"httpx",
8686
"asgi-lifespan",
8787
"psutil",
88+
"black>=23.11.0",
8889
]
8990
[tool.pytest.ini_options]
9091
markers = [

sse_starlette/sse.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
import anyio
1919
from starlette.background import BackgroundTask
2020
from starlette.concurrency import iterate_in_threadpool
21-
from starlette.responses import AsyncContentStream, ContentStream, Response
21+
from starlette.responses import Response
2222
from starlette.types import Receive, Scope, Send
2323

2424
_log = logging.getLogger(__name__)
@@ -139,6 +139,12 @@ def ensure_bytes(data: Union[bytes, dict, ServerSentEvent, Any], sep: str) -> by
139139
return ServerSentEvent(str(data), sep=sep).encode()
140140

141141

142+
Content = Union[str, bytes, dict, ServerSentEvent]
143+
SyncContentStream = Iterator[Content]
144+
AsyncContentStream = AsyncIterable[Content]
145+
ContentStream = Union[AsyncContentStream, SyncContentStream]
146+
147+
142148
class EventSourceResponse(Response):
143149
"""Implements the ServerSentEvent Protocol:
144150
https://www.w3.org/TR/2009/WD-eventsource-20090421/

0 commit comments

Comments
 (0)