Files
fastapi-cache/fastapi_cache/types.py
Martijn Pieters b1dc05a89a key_builder type; args and kwargs are always given
These arguments are never set to None so don't need to be optional. They
are always a tuple and a dict but can be empty.
2023-04-28 16:50:30 +01:00

22 lines
521 B
Python

from typing import Any, Awaitable, Callable, Optional, Protocol, Union
from starlette.requests import Request
from starlette.responses import Response
_Func = Callable[..., Any]
class KeyBuilder(Protocol):
def __call__(
self,
_function: _Func,
_namespace: str = ...,
*,
request: Optional[Request] = ...,
response: Optional[Response] = ...,
args: tuple[Any, ...] = ...,
kwargs: dict[str, Any] = ...,
) -> Union[Awaitable[str], str]:
...