diff --git a/src/datastar_py/django.py b/src/datastar_py/django.py index 955a343..f3ce295 100644 --- a/src/datastar_py/django.py +++ b/src/datastar_py/django.py @@ -1,9 +1,9 @@ from __future__ import annotations -from collections.abc import Awaitable, Callable, Mapping +from collections.abc import Awaitable, Callable, Coroutine, Mapping from functools import wraps from inspect import isasyncgenfunction, isawaitable, iscoroutinefunction -from typing import Any, ParamSpec +from typing import Any, ParamSpec, overload from django.http import HttpRequest from django.http import StreamingHttpResponse as _StreamingHttpResponse @@ -44,6 +44,18 @@ def __init__( P = ParamSpec("P") +@overload +def datastar_response( + func: Callable[P, Coroutine[Any, Any, DatastarEvents]], +) -> Callable[P, Coroutine[Any, Any, DatastarResponse]]: ... + + +@overload +def datastar_response( + func: Callable[P, DatastarEvents], +) -> Callable[P, DatastarResponse]: ... + + def datastar_response( func: Callable[P, Awaitable[DatastarEvents] | DatastarEvents], ) -> Callable[P, Awaitable[DatastarResponse] | DatastarResponse]: