From ac77f8fbc343daf102efe213d9669b97204fe519 Mon Sep 17 00:00:00 2001 From: James Ward Date: Fri, 17 Oct 2025 17:50:02 -0400 Subject: [PATCH] feat: match signatures to cachetools v6 --- src/cachetools_async/decorators.py | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/src/cachetools_async/decorators.py b/src/cachetools_async/decorators.py index 281db95..3ec98ae 100644 --- a/src/cachetools_async/decorators.py +++ b/src/cachetools_async/decorators.py @@ -10,10 +10,14 @@ Optional, Protocol, TypeVar, + TYPE_CHECKING ) from cachetools.keys import hashkey, methodkey +if TYPE_CHECKING: + from threading import Condition + _KT = TypeVar("_KT") _T = TypeVar("_T") @@ -39,6 +43,7 @@ def cached( cache: Optional[MutableMapping[_KT, Future]], key: Callable[..., _KT] = hashkey, lock: Optional[ContextManager[Any]] = None, + cond: Optional[Condition] = None, info: bool = False, ) -> IdentityFunction: """Wrap a function to save results in a cache.""" @@ -48,6 +53,9 @@ def cached( if lock is not None: raise NotImplementedError("cachetools_async does not support `lock`") + if cond is not None: + raise NotImplementedError("cachetools_async does not support `cond`") + def decorator(fn: Callable[..., Awaitable]): if not iscoroutinefunction(fn): raise TypeError("Expected Coroutine function, got {}".format(fn)) @@ -109,11 +117,15 @@ def cachedmethod( cache: Callable[[Any], Optional[MutableMapping[_KT, Future]]], key: Callable[..., _KT] = methodkey, lock: Optional[Callable[[Any], ContextManager[Any]]] = None, + cond: Optional[Condition] = None ) -> IdentityFunction: """Wrap a class or instance method to save results in a cache.""" if lock is not None: raise NotImplementedError("cachetools_async does not support `lock`") + if cond is not None: + raise NotImplementedError("cachetools_async does not support `cond`") + def decorator(method: Callable[..., Awaitable]): if not iscoroutinefunction(method): raise TypeError("Expected Coroutine function, got {}".format(method))