Skip to content

Commit

Permalink
OPT: improve typing for _CachedCallable πŸ§‘β€πŸ’»
Browse files Browse the repository at this point in the history
  • Loading branch information
eigenein committed Dec 5, 2023
1 parent 1c760c3 commit 2dc6d31
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
4 changes: 2 additions & 2 deletions cachetory/decorators/async_.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ def cached(
exclude: Optional callable to prevent a key-value pair from being cached if the callable returns true.
"""

def wrap(callable_: Callable[P, Awaitable[ValueT]]) -> _CachedCallable[P, Awaitable[ValueT]]:
def wrap(callable_: Callable[P, Awaitable[ValueT]], /) -> _CachedCallable[P, Awaitable[ValueT]]:
get_cache = into_async_callable(cache)
get_time_to_live = into_async_callable(time_to_live)
exclude_: Callable[[str, ValueT], Awaitable[bool]] | None = (
Expand Down Expand Up @@ -92,7 +92,7 @@ async def purge(*args: P.args, **kwargs: P.kwargs) -> bool:
class _CachedCallable(Protocol[P, ValueT_co]):
"""Protocol of the wrapped callable."""

def __call__(self, *args: P.args, **kwargs: P.kwargs) -> ValueT_co:
def __call__(*args: P.args, **kwargs: P.kwargs) -> ValueT_co:
...

async def purge(*args: P.args, **kwargs: P.kwargs) -> bool:
Expand Down
4 changes: 2 additions & 2 deletions cachetory/decorators/sync.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ def cached(
exclude: Optional callable to prevent a key-value pair from being cached if the callable returns true.
"""

def wrap(callable_: Callable[P, ValueT]) -> _CachedCallable[P, ValueT]:
def wrap(callable_: Callable[P, ValueT], /) -> _CachedCallable[P, ValueT]:
get_cache = into_callable(cache)
get_time_to_live = into_callable(time_to_live)

Expand Down Expand Up @@ -79,7 +79,7 @@ def purge(*args: P.args, **kwargs: P.kwargs) -> bool:
class _CachedCallable(Protocol[P, ValueT_co]):
"""Protocol of the wrapped callable."""

def __call__(self, *args: P.args, **kwargs: P.kwargs) -> ValueT_co:
def __call__(*args: P.args, **kwargs: P.kwargs) -> ValueT_co:
...

def purge(*args: P.args, **kwargs: P.kwargs) -> bool:
Expand Down

0 comments on commit 2dc6d31

Please sign in to comment.