11import random
22from collections .abc import Callable , Iterator , MutableMapping , Sequence
33from contextlib import AbstractContextManager
4- from typing import (
5- Any ,
6- Final ,
7- Generic ,
8- Literal ,
9- NamedTuple ,
10- Protocol ,
11- TypeVar ,
12- overload ,
13- type_check_only ,
14- )
15-
16- __all__ : Final = (
17- "Cache" ,
18- "FIFOCache" ,
19- "LFUCache" ,
20- "LRUCache" ,
21- "RRCache" ,
22- "TLRUCache" ,
23- "TTLCache" ,
24- "cached" ,
25- "cachedmethod" ,
26- )
4+ from typing import Any , Final , Generic , Literal , NamedTuple , Protocol , TypeVar , overload , type_check_only
5+
6+ __all__ : Final = ("Cache" , "FIFOCache" , "LFUCache" , "LRUCache" , "RRCache" , "TLRUCache" , "TTLCache" , "cached" , "cachedmethod" )
277__version__ : str
288
299_KT = TypeVar ("_KT" )
@@ -35,9 +15,7 @@ _KT2 = TypeVar("_KT2")
3515_VT2 = TypeVar ("_VT2" )
3616
3717class Cache (MutableMapping [_KT , _VT ]):
38- def __init__ (
39- self , maxsize : float , getsizeof : Callable [[_VT ], float ] | None = None
40- ) -> None : ...
18+ def __init__ (self , maxsize : float , getsizeof : Callable [[_VT ], float ] | None = None ) -> None : ...
4119 def __getitem__ (self , key : _KT ) -> _VT : ...
4220 def __setitem__ (self , key : _KT , value : _VT ) -> None : ...
4321 def __delitem__ (self , key : _KT ) -> None : ...
@@ -71,12 +49,7 @@ class RRCache(Cache[_KT, _VT]):
7149 def choice (self ) -> Callable [[Sequence [_KT ]], _KT ]: ...
7250
7351class _TimedCache (Cache [_KT , _VT ], Generic [_KT , _VT , _TT ]):
74- def __init__ (
75- self ,
76- maxsize : float ,
77- timer : Callable [[], _TT ],
78- getsizeof : Callable [[_VT ], float ] | None = None ,
79- ) -> None : ...
52+ def __init__ (self , maxsize : float , timer : Callable [[], _TT ], getsizeof : Callable [[_VT ], float ] | None = None ) -> None : ...
8053
8154 class _Timer (AbstractContextManager [_T ]):
8255 def __init__ (self , timer : Callable [[], _T ]) -> None : ...
@@ -91,11 +64,7 @@ class _TimedCache(Cache[_KT, _VT], Generic[_KT, _VT, _TT]):
9164class TTLCache (_TimedCache [_KT , _VT , _TT ]):
9265 @overload
9366 def __init__ (
94- self : TTLCache [_KT2 , _VT2 , float ],
95- maxsize : float ,
96- ttl : float ,
97- * ,
98- getsizeof : Callable [[_VT2 ], float ] | None = None ,
67+ self : TTLCache [_KT2 , _VT2 , float ], maxsize : float , ttl : float , * , getsizeof : Callable [[_VT2 ], float ] | None = None
9968 ) -> None : ...
10069 @overload
10170 def __init__ (
@@ -139,9 +108,7 @@ class _CacheInfo(NamedTuple):
139108@type_check_only
140109class _AbstractCondition (AbstractContextManager [Any ], Protocol ):
141110 # implementation an unit tests do not use plain wait() and notify()
142- def wait_for (
143- self , predicate : Callable [[], _T ], timeout : float | None = None
144- ) -> _T : ...
111+ def wait_for (self , predicate : Callable [[], _T ], timeout : float | None = None ) -> _T : ...
145112 def notify_all (self ) -> None : ...
146113
147114@type_check_only
0 commit comments