massive update, probably broken
[dotfiles/.git] / .config / coc / extensions / node_modules / coc-pyright / node_modules / pyright / dist / typeshed-fallback / stubs / cachetools / cachetools / __init__.pyi
1 from _typeshed import IdentityFunction
2 from collections.abc import Iterator, Sequence
3 from contextlib import AbstractContextManager
4 from typing import Any, Callable, Generic, MutableMapping, TypeVar, overload
5
6 _KT = TypeVar("_KT")
7 _VT = TypeVar("_VT")
8 _T = TypeVar("_T")
9
10 class Cache(MutableMapping[_KT, _VT], Generic[_KT, _VT]):
11     def __init__(self, maxsize: float, getsizeof: Callable[[_VT], float] | None = ...) -> None: ...
12     def __getitem__(self, key: _KT) -> _VT: ...
13     def __setitem__(self, key: _KT, value: _VT) -> None: ...
14     def __delitem__(self, key: _KT) -> None: ...
15     def __iter__(self) -> Iterator[_KT]: ...
16     def __len__(self) -> int: ...
17     @overload  # type: ignore[override]
18     def pop(self, key: _KT) -> _VT: ...
19     @overload
20     def pop(self, key: _KT, default: _VT | _T) -> _VT | _T: ...
21     def setdefault(self, key: _KT, default: _VT | None = ...) -> _VT: ...
22     @property
23     def maxsize(self) -> float: ...
24     @property
25     def currsize(self) -> float: ...
26     @staticmethod
27     def getsizeof(value: _VT) -> float: ...
28
29 class FIFOCache(Cache[_KT, _VT]):
30     def __init__(self, maxsize: float, getsizeof: Callable[[_VT], float] | None = ...) -> None: ...
31
32 class LFUCache(Cache[_KT, _VT]):
33     def __init__(self, maxsize: float, getsizeof: Callable[[_VT], float] | None = ...) -> None: ...
34
35 class LRUCache(Cache[_KT, _VT]):
36     def __init__(self, maxsize: float, getsizeof: Callable[[_VT], float] | None = ...) -> None: ...
37
38 class MRUCache(Cache[_KT, _VT]):
39     def __init__(self, maxsize: float, getsizeof: Callable[[_VT], float] | None = ...) -> None: ...
40
41 class RRCache(Cache[_KT, _VT]):
42     def __init__(
43         self, maxsize: float, choice: Callable[[Sequence[_KT]], _KT] | None = ..., getsizeof: Callable[[_VT], float] | None = ...
44     ) -> None: ...
45     @property
46     def choice(self) -> Callable[[Sequence[_KT]], _KT]: ...
47
48 class TTLCache(Cache[_KT, _VT]):
49     def __init__(
50         self, maxsize: float, ttl: float, timer: Callable[[], float] = ..., getsizeof: Callable[[_VT], float] | None = ...
51     ) -> None: ...
52     @property
53     def currsize(self) -> float: ...
54     @property
55     def timer(self) -> Callable[[], float]: ...
56     @property
57     def ttl(self) -> float: ...
58     def expire(self, time: float | None = ...) -> None: ...
59
60 def cached(
61     cache: MutableMapping[_KT, Any] | None, key: Callable[..., _KT] = ..., lock: AbstractContextManager[Any] | None = ...
62 ) -> IdentityFunction: ...
63 def cachedmethod(
64     cache: Callable[[Any], MutableMapping[_KT, Any] | None],
65     key: Callable[..., _KT] = ...,
66     lock: Callable[[Any], AbstractContextManager[Any]] | None = ...,
67 ) -> IdentityFunction: ...