mirror of
https://github.com/davidhalter/typeshed.git
synced 2025-12-26 13:51:30 +08:00
Add back and update cachetools stubs to cachetools 4.2.4 (#6096)
This commit is contained in:
20
stubs/cachetools/@tests/stubtest_allowlist.txt
Normal file
20
stubs/cachetools/@tests/stubtest_allowlist.txt
Normal file
@@ -0,0 +1,20 @@
|
||||
cachetools.Cache.get
|
||||
cachetools.LFUCache.__delitem__
|
||||
cachetools.LFUCache.__getitem__
|
||||
cachetools.LFUCache.__setitem__
|
||||
cachetools.LRUCache.__delitem__
|
||||
cachetools.LRUCache.__getitem__
|
||||
cachetools.LRUCache.__setitem__
|
||||
cachetools.TTLCache.__delitem__
|
||||
cachetools.TTLCache.__getitem__
|
||||
cachetools.TTLCache.__setitem__
|
||||
cachetools.cache.Cache.get
|
||||
cachetools.lfu.LFUCache.__delitem__
|
||||
cachetools.lfu.LFUCache.__getitem__
|
||||
cachetools.lfu.LFUCache.__setitem__
|
||||
cachetools.lru.LRUCache.__delitem__
|
||||
cachetools.lru.LRUCache.__getitem__
|
||||
cachetools.lru.LRUCache.__setitem__
|
||||
cachetools.ttl.TTLCache.__delitem__
|
||||
cachetools.ttl.TTLCache.__getitem__
|
||||
cachetools.ttl.TTLCache.__setitem__
|
||||
1
stubs/cachetools/METADATA.toml
Normal file
1
stubs/cachetools/METADATA.toml
Normal file
@@ -0,0 +1 @@
|
||||
version = "4.2"
|
||||
78
stubs/cachetools/cachetools/__init__.pyi
Normal file
78
stubs/cachetools/cachetools/__init__.pyi
Normal file
@@ -0,0 +1,78 @@
|
||||
from _typeshed import IdentityFunction
|
||||
from collections.abc import Iterator, Sequence
|
||||
from typing import Any, Callable, ContextManager, Generic, MutableMapping, TypeVar
|
||||
|
||||
_KT = TypeVar("_KT")
|
||||
_VT = TypeVar("_VT")
|
||||
|
||||
class Cache(MutableMapping[_KT, _VT], Generic[_KT, _VT]):
|
||||
def __init__(self, maxsize: float, getsizeof: Callable[[_VT], float] | None = ...) -> None: ...
|
||||
def __getitem__(self, key: _KT) -> _VT: ...
|
||||
def __setitem__(self, key: _KT, value: _VT) -> None: ...
|
||||
def __delitem__(self, key: _KT) -> None: ...
|
||||
def __iter__(self) -> Iterator[_KT]: ...
|
||||
def __len__(self) -> int: ...
|
||||
@property
|
||||
def maxsize(self) -> float: ...
|
||||
@property
|
||||
def currsize(self) -> float: ...
|
||||
@staticmethod
|
||||
def getsizeof(value: _VT) -> float: ...
|
||||
|
||||
class FIFOCache(Cache[_KT, _VT]):
|
||||
def __init__(self, maxsize: float, getsizeof: Callable[[_VT], float] | None = ...) -> None: ...
|
||||
# TODO: add types to these, currently using what is defined in superclass
|
||||
# def __setitem__(self, key, value, cache_setitem=...) -> None: ...
|
||||
# def __delitem__(self, key, cache_delitem=...) -> None: ...
|
||||
# def popitem(self): ...
|
||||
|
||||
class LFUCache(Cache[_KT, _VT]):
|
||||
def __init__(self, maxsize: float, getsizeof: Callable[[_VT], float] | None = ...) -> None: ...
|
||||
def __getitem__(self, key: _KT, cache_getitem: Callable[[_KT], _VT] = ...) -> _VT: ...
|
||||
def __setitem__(self, key: _KT, value: _VT, cache_setitem: Callable[[_KT, _VT], None] = ...) -> None: ...
|
||||
def __delitem__(self, key: _KT, cache_delitem: Callable[[_KT], None] = ...) -> None: ...
|
||||
|
||||
class LRUCache(Cache[_KT, _VT]):
|
||||
def __init__(self, maxsize: float, getsizeof: Callable[[_VT], float] | None = ...) -> None: ...
|
||||
def __getitem__(self, key: _KT, cache_getitem: Callable[[_KT], _VT] = ...) -> _VT: ...
|
||||
def __setitem__(self, key: _KT, value: _VT, cache_setitem: Callable[[_KT, _VT], None] = ...) -> None: ...
|
||||
def __delitem__(self, key: _KT, cache_delitem: Callable[[_KT], None] = ...) -> None: ...
|
||||
|
||||
class MRUCache(Cache[_KT, _VT]):
|
||||
def __init__(self, maxsize: float, getsizeof: Callable[[_VT], float] | None = ...) -> None: ...
|
||||
# TODO: add types to these, currently using what is defined in superclass
|
||||
# def __getitem__(self, key, cache_getitem=...): ...
|
||||
# def __setitem__(self, key, value, cache_setitem=...) -> None: ...
|
||||
# def __delitem__(self, key, cache_delitem=...) -> None: ...
|
||||
# def popitem(self): ...
|
||||
|
||||
class RRCache(Cache[_KT, _VT]):
|
||||
def __init__(
|
||||
self, maxsize: float, choice: Callable[[Sequence[_KT]], _KT] | None = ..., getsizeof: Callable[[_VT], float] | None = ...
|
||||
) -> None: ...
|
||||
@property
|
||||
def choice(self) -> Callable[[Sequence[_KT]], _KT]: ...
|
||||
|
||||
class TTLCache(Cache[_KT, _VT]):
|
||||
def __init__(
|
||||
self, maxsize: float, ttl: float, timer: Callable[[], float] = ..., getsizeof: Callable[[_VT], float] | None = ...
|
||||
) -> None: ...
|
||||
def __getitem__(self, key: _KT, cache_getitem: Callable[[_KT], _VT] = ...) -> _VT: ...
|
||||
def __setitem__(self, key: _KT, value: _VT, cache_setitem: Callable[[_KT, _VT], None] = ...) -> None: ...
|
||||
def __delitem__(self, key: _KT, cache_delitem: Callable[[_KT], None] = ...) -> None: ...
|
||||
def __iter__(self) -> Iterator[_KT]: ...
|
||||
def __len__(self) -> int: ...
|
||||
@property
|
||||
def currsize(self) -> float: ...
|
||||
@property
|
||||
def timer(self) -> Callable[[], float]: ...
|
||||
@property
|
||||
def ttl(self) -> float: ...
|
||||
def expire(self, time: float | None = ...) -> None: ...
|
||||
|
||||
def cached(
|
||||
cache: MutableMapping[_KT, Any] | None, key: Callable[..., _KT] = ..., lock: ContextManager[Any] | None = ...
|
||||
) -> IdentityFunction: ...
|
||||
def cachedmethod(
|
||||
cache: Callable[[Any], MutableMapping[_KT, Any] | None], key: Callable[..., _KT] = ..., lock: ContextManager[Any] | None = ...
|
||||
) -> IdentityFunction: ...
|
||||
2
stubs/cachetools/cachetools/cache.pyi
Normal file
2
stubs/cachetools/cachetools/cache.pyi
Normal file
@@ -0,0 +1,2 @@
|
||||
# this module is deprecated
|
||||
from . import Cache as Cache
|
||||
2
stubs/cachetools/cachetools/fifo.pyi
Normal file
2
stubs/cachetools/cachetools/fifo.pyi
Normal file
@@ -0,0 +1,2 @@
|
||||
# this module is deprecated
|
||||
from . import FIFOCache as FIFOCache
|
||||
13
stubs/cachetools/cachetools/func.pyi
Normal file
13
stubs/cachetools/cachetools/func.pyi
Normal file
@@ -0,0 +1,13 @@
|
||||
from _typeshed import IdentityFunction
|
||||
from typing import Callable, Sequence, TypeVar
|
||||
|
||||
_T = TypeVar("_T")
|
||||
|
||||
def fifo_cache(maxsize: float = ..., typed: bool = ...) -> IdentityFunction: ...
|
||||
def lfu_cache(maxsize: float = ..., typed: bool = ...) -> IdentityFunction: ...
|
||||
def lru_cache(maxsize: float = ..., typed: bool = ...) -> IdentityFunction: ...
|
||||
def mru_cache(maxsize: float = ..., typed: bool = ...) -> IdentityFunction: ...
|
||||
def rr_cache(maxsize: float = ..., choice: Callable[[Sequence[_T]], _T] | None = ..., typed: bool = ...) -> IdentityFunction: ...
|
||||
def ttl_cache(
|
||||
maxsize: float = ..., ttl: float = ..., timer: Callable[[], float] = ..., typed: bool = ...
|
||||
) -> IdentityFunction: ...
|
||||
4
stubs/cachetools/cachetools/keys.pyi
Normal file
4
stubs/cachetools/cachetools/keys.pyi
Normal file
@@ -0,0 +1,4 @@
|
||||
from typing import Hashable, Tuple
|
||||
|
||||
def hashkey(*args: Hashable, **kwargs: Hashable) -> Tuple[Hashable, ...]: ...
|
||||
def typedkey(*args: Hashable, **kwargs: Hashable) -> Tuple[Hashable, ...]: ...
|
||||
2
stubs/cachetools/cachetools/lfu.pyi
Normal file
2
stubs/cachetools/cachetools/lfu.pyi
Normal file
@@ -0,0 +1,2 @@
|
||||
# this module is deprecated
|
||||
from . import LFUCache as LFUCache
|
||||
2
stubs/cachetools/cachetools/lru.pyi
Normal file
2
stubs/cachetools/cachetools/lru.pyi
Normal file
@@ -0,0 +1,2 @@
|
||||
# this module is deprecated
|
||||
from . import LRUCache as LRUCache
|
||||
2
stubs/cachetools/cachetools/mru.pyi
Normal file
2
stubs/cachetools/cachetools/mru.pyi
Normal file
@@ -0,0 +1,2 @@
|
||||
# this module is deprecated
|
||||
from . import MRUCache as MRUCache
|
||||
2
stubs/cachetools/cachetools/rr.pyi
Normal file
2
stubs/cachetools/cachetools/rr.pyi
Normal file
@@ -0,0 +1,2 @@
|
||||
# this module is deprecated
|
||||
from . import RRCache as RRCache
|
||||
2
stubs/cachetools/cachetools/ttl.pyi
Normal file
2
stubs/cachetools/cachetools/ttl.pyi
Normal file
@@ -0,0 +1,2 @@
|
||||
# this module is deprecated
|
||||
from . import TTLCache as TTLCache
|
||||
Reference in New Issue
Block a user