Skip to content

Commit 45cde4e

Browse files
authored
Fix runtime type introspection for datastar_response decorator (#2)
1 parent d236d10 commit 45cde4e

File tree

4 files changed

+5
-5
lines changed

4 files changed

+5
-5
lines changed

src/datastar_py/litestar.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ async def wrapper(*args: P.args, **kwargs: P.kwargs) -> DatastarResponse:
7777
return DatastarResponse(await r)
7878
return DatastarResponse(r)
7979

80-
wrapper.__annotations__["return"] = "DatastarResponse"
80+
wrapper.__annotations__["return"] = DatastarResponse
8181
return wrapper
8282

8383

src/datastar_py/quart.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ async def wrapper(*args: P.args, **kwargs: P.kwargs) -> DatastarResponse:
5555
return DatastarResponse(stream_with_context(func)(*args, **kwargs))
5656
return DatastarResponse(await copy_current_request_context(func)(*args, **kwargs))
5757

58-
wrapper.__annotations__["return"] = "DatastarResponse"
58+
wrapper.__annotations__["return"] = DatastarResponse
5959
return wrapper
6060

6161

src/datastar_py/sanic.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
from collections.abc import Awaitable, Collection, Mapping
44
from functools import wraps
55
from inspect import isasyncgen, isgenerator
6-
from typing import Any, Callable, ParamSpec
6+
from typing import Any, Callable, ParamSpec, Union
77

88
from sanic import HTTPResponse, Request
99

@@ -87,7 +87,7 @@ async def wrapper(*args: P.args, **kwargs: P.kwargs) -> DatastarResponse | None:
8787
return None
8888
return DatastarResponse(r)
8989

90-
wrapper.__annotations__["return"] = "DatastarResponse"
90+
wrapper.__annotations__["return"] = Union[DatastarResponse, None]
9191
return wrapper
9292

9393

src/datastar_py/starlette.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ async def wrapper(*args: P.args, **kwargs: P.kwargs) -> DatastarResponse:
6767
return DatastarResponse(await r)
6868
return DatastarResponse(r)
6969

70-
wrapper.__annotations__["return"] = "DatastarResponse"
70+
wrapper.__annotations__["return"] = DatastarResponse
7171
return wrapper
7272

7373

0 commit comments

Comments
 (0)