|
1 | 1 | from _typeshed import IdentityFunction, Unused |
2 | 2 | from collections.abc import Callable, Iterator, MutableMapping, Sequence |
3 | 3 | from contextlib import AbstractContextManager |
| 4 | +from threading import Condition |
4 | 5 | from typing import Any, TypeVar, overload |
5 | 6 | from typing_extensions import deprecated |
6 | 7 |
|
7 | | -__all__ = ("Cache", "FIFOCache", "LFUCache", "LRUCache", "MRUCache", "RRCache", "TLRUCache", "TTLCache", "cached", "cachedmethod") |
| 8 | +__all__ = ("Cache", "FIFOCache", "LFUCache", "LRUCache", "RRCache", "TLRUCache", "TTLCache", "cached", "cachedmethod") |
8 | 9 | __version__: str |
9 | 10 |
|
10 | 11 | _KT = TypeVar("_KT") |
@@ -38,9 +39,6 @@ class FIFOCache(Cache[_KT, _VT]): ... |
38 | 39 | class LFUCache(Cache[_KT, _VT]): ... |
39 | 40 | class LRUCache(Cache[_KT, _VT]): ... |
40 | 41 |
|
41 | | -@deprecated("@mru_cache is deprecated") |
42 | | -class MRUCache(Cache[_KT, _VT]): ... |
43 | | - |
44 | 42 | class RRCache(Cache[_KT, _VT]): |
45 | 43 | @overload |
46 | 44 | def __init__(self, maxsize: float, choice: None = None, getsizeof: None = None) -> None: ... |
@@ -99,14 +97,25 @@ class TLRUCache(_TimedCache[_KT, _VT]): |
99 | 97 | def ttu(self) -> Callable[[_KT, _VT, float], float]: ... |
100 | 98 | def expire(self, time: float | None = None) -> list[tuple[_KT, _VT]]: ... |
101 | 99 |
|
| 100 | +@overload |
102 | 101 | def cached( |
103 | 102 | cache: MutableMapping[_KT, Any] | None, |
104 | 103 | key: Callable[..., _KT] = ..., |
105 | 104 | lock: AbstractContextManager[Any] | None = None, |
| 105 | + condition: Condition | None = None, |
106 | 106 | info: bool = False, |
107 | 107 | ) -> IdentityFunction: ... |
| 108 | +@overload |
| 109 | +@deprecated("Passing `info` as positional parameter is deprecated.") |
| 110 | +def cached( |
| 111 | + cache: MutableMapping[_KT, Any] | None, |
| 112 | + key: Callable[..., _KT] = ..., |
| 113 | + lock: AbstractContextManager[Any] | None = None, |
| 114 | + condition: bool | None = None, |
| 115 | +) -> IdentityFunction: ... |
108 | 116 | def cachedmethod( |
109 | 117 | cache: Callable[[Any], MutableMapping[_KT, Any] | None], |
110 | 118 | key: Callable[..., _KT] = ..., |
111 | 119 | lock: Callable[[Any], AbstractContextManager[Any]] | None = None, |
| 120 | + condition: Condition | None = None, |
112 | 121 | ) -> IdentityFunction: ... |
0 commit comments