Added typehint for Callable[P, R] in the decorator

This commit is contained in:
fheinze-tkb
2024-06-04 13:59:50 +02:00
committed by GitHub
parent 865dba19a5
commit 17fb72437a

View File

@@ -90,7 +90,7 @@ def cache(
key_builder: Optional[KeyBuilder] = None, key_builder: Optional[KeyBuilder] = None,
namespace: str = "", namespace: str = "",
injected_dependency_namespace: str = "__fastapi_cache", injected_dependency_namespace: str = "__fastapi_cache",
) -> Callable[[Callable[P, Awaitable[R]]], Callable[P, Awaitable[Union[R, Response]]]]: ) -> Callable[[Union[Callable[P, Awaitable[R]], Callable[P, R]]], Callable[P, Awaitable[Union[R, Response]]]]:
""" """
cache all function cache all function
:param namespace: :param namespace:
@@ -113,7 +113,7 @@ def cache(
) )
def wrapper( def wrapper(
func: Callable[P, Awaitable[R]] func: Union[Callable[P, Awaitable[R]], Callable[P, R]]
) -> Callable[P, Awaitable[Union[R, Response]]]: ) -> Callable[P, Awaitable[Union[R, Response]]]:
# get_typed_signature ensures that any forward references are resolved first # get_typed_signature ensures that any forward references are resolved first
wrapped_signature = get_typed_signature(func) wrapped_signature = get_typed_signature(func)