From 5b6c741347ae13c730cfd63d5537d97be9c99afc Mon Sep 17 00:00:00 2001 From: stubsabot <> Date: Sun, 1 Nov 2026 00:16:53 +0000 Subject: [PATCH] [stubsabot] Remove cachetools as ships py.typed file Typeshed release: https://pypi.org/pypi/types-cachetools Typeshed stubs: https://github.com/python/typeshed/tree/main/stubs/cachetools --- .../cachetools/@tests/stubtest_allowlist.txt | 21 -- .../@tests/test_cases/check_cachetools.py | 104 ---------- stubs/cachetools/METADATA.toml | 3 - stubs/cachetools/cachetools/__init__.pyi | 183 ------------------ stubs/cachetools/cachetools/func.pyi | 54 ------ stubs/cachetools/cachetools/keys.pyi | 10 - 6 files changed, 375 deletions(-) delete mode 100644 stubs/cachetools/@tests/stubtest_allowlist.txt delete mode 100644 stubs/cachetools/@tests/test_cases/check_cachetools.py delete mode 100644 stubs/cachetools/METADATA.toml delete mode 100644 stubs/cachetools/cachetools/__init__.pyi delete mode 100644 stubs/cachetools/cachetools/func.pyi delete mode 100644 stubs/cachetools/cachetools/keys.pyi diff --git a/stubs/cachetools/@tests/stubtest_allowlist.txt b/stubs/cachetools/@tests/stubtest_allowlist.txt deleted file mode 100644 index a0bcfbfe73bc..000000000000 --- a/stubs/cachetools/@tests/stubtest_allowlist.txt +++ /dev/null @@ -1,21 +0,0 @@ -cachetools.Cache.get - -# stubs omit defaulted arguments that are meant to be optimizations, not provided by user -cachetools.FIFOCache.__delitem__ -cachetools.FIFOCache.__setitem__ -cachetools.LFUCache.__delitem__ -cachetools.LFUCache.__getitem__ -cachetools.LFUCache.__setitem__ -cachetools.LRUCache.__delitem__ -cachetools.LRUCache.__getitem__ -cachetools.LRUCache.__setitem__ -cachetools.RRCache.__delitem__ -cachetools.RRCache.__setitem__ -cachetools.TLRUCache.__delitem__ -cachetools.TLRUCache.__getitem__ -cachetools.TLRUCache.__setitem__ -cachetools.TTLCache.__delitem__ -cachetools.TTLCache.__getitem__ -cachetools.TTLCache.__setitem__ -cachetools._TimedCache.__len__ -cachetools._TimedCache.__repr__ diff --git a/stubs/cachetools/@tests/test_cases/check_cachetools.py b/stubs/cachetools/@tests/test_cases/check_cachetools.py deleted file mode 100644 index cd890c76a209..000000000000 --- a/stubs/cachetools/@tests/test_cases/check_cachetools.py +++ /dev/null @@ -1,104 +0,0 @@ -from __future__ import annotations - -from collections.abc import Hashable -from typing import Any -from typing_extensions import assert_type - -from cachetools import LRUCache, cached, keys as cachekeys -from cachetools.func import fifo_cache, lfu_cache, lru_cache, rr_cache, ttl_cache - -# Tests for cachetools.cached - -# Explicitly parameterize the cache to avoid Unknown types -cache_inst: LRUCache[int, int] = LRUCache(maxsize=128) - - -@cached(cache_inst) -def check_cached(x: int) -> int: - return x * 2 - - -assert_type(check_cached(3), int) -# Methods cache_info/cache_clear are only present when info=True; do not access them here. - - -@cached(cache_inst, info=True) -def check_cached_with_info(x: int) -> int: - return x + 1 - - -assert_type(check_cached_with_info(4), int) -assert_type(check_cached_with_info.cache_info().misses, int) -check_cached_with_info.cache_clear() - - -# Tests for cachetools.func decorators - - -@lru_cache -def lru_noparens(x: int) -> int: - return x * 2 - - -@lru_cache(maxsize=32) -def lru_with_maxsize(x: int) -> int: - return x * 3 - - -assert_type(lru_noparens(3), int) -assert_type(lru_with_maxsize(3), int) -assert_type(lru_noparens.cache_info().hits, int) -assert_type(lru_with_maxsize.cache_info().misses, int) -assert_type(lru_with_maxsize.cache_parameters(), dict[str, Any]) -lru_with_maxsize.cache_clear() - - -@fifo_cache -def fifo_func(x: int) -> int: - return x - - -@lfu_cache -def lfu_func(x: int) -> int: - return x - - -@rr_cache -def rr_func(x: int) -> int: - return x - - -@ttl_cache -def ttl_func(x: int) -> int: - return x - - -assert_type(fifo_func(1), int) -assert_type(lfu_func(1), int) -assert_type(rr_func(1), int) -assert_type(ttl_func(1), int) -assert_type(fifo_func.cache_info().currsize, float) -assert_type(lfu_func.cache_parameters(), dict[str, Any]) - - -# Tests for cachetools.keys - -k1 = cachekeys.hashkey(1, "a") -assert_type(k1, tuple[Hashable, ...]) - - -class C: - def method(self, a: int) -> int: - return a - - -inst = C() - -k2 = cachekeys.methodkey(inst, 5) -assert_type(k2, tuple[Hashable, ...]) - -k3 = cachekeys.typedkey(1, "x") -assert_type(k3, tuple[Hashable, ...]) - -k4 = cachekeys.typedmethodkey(inst, 2) -assert_type(k4, tuple[Hashable, ...]) diff --git a/stubs/cachetools/METADATA.toml b/stubs/cachetools/METADATA.toml deleted file mode 100644 index 1099004a4a54..000000000000 --- a/stubs/cachetools/METADATA.toml +++ /dev/null @@ -1,3 +0,0 @@ -version = "7.0.*" -upstream-repository = "https://github.com/tkem/cachetools" -obsolete-since = {version = "7.1.0", date = "2026-05-01"} diff --git a/stubs/cachetools/cachetools/__init__.pyi b/stubs/cachetools/cachetools/__init__.pyi deleted file mode 100644 index add55e47a10d..000000000000 --- a/stubs/cachetools/cachetools/__init__.pyi +++ /dev/null @@ -1,183 +0,0 @@ -import random -from collections.abc import Callable, Iterator, MutableMapping, Sequence -from contextlib import AbstractContextManager -from typing import Any, Final, Generic, Literal, NamedTuple, Protocol, TypeVar, overload, type_check_only - -__all__: Final = ("Cache", "FIFOCache", "LFUCache", "LRUCache", "RRCache", "TLRUCache", "TTLCache", "cached", "cachedmethod") -__version__: str - -_KT = TypeVar("_KT") -_VT = TypeVar("_VT") -_TT = TypeVar("_TT", default=float) -_T = TypeVar("_T") -_R = TypeVar("_R") -_KT2 = TypeVar("_KT2") -_VT2 = TypeVar("_VT2") - -class Cache(MutableMapping[_KT, _VT]): - def __init__(self, maxsize: float, getsizeof: Callable[[_VT], float] | None = None) -> None: ... - def __getitem__(self, key: _KT) -> _VT: ... - def __setitem__(self, key: _KT, value: _VT) -> None: ... - def __delitem__(self, key: _KT) -> None: ... - def __missing__(self, key: _KT) -> _VT: ... - def __iter__(self) -> Iterator[_KT]: ... - def __len__(self) -> int: ... - - @overload - def pop(self, key: _KT) -> _VT: ... - @overload - def pop(self, key: _KT, default: _VT | _T) -> _VT | _T: ... - - def setdefault(self, key: _KT, default: _VT | None = None) -> _VT: ... - @property - def maxsize(self) -> float: ... - @property - def currsize(self) -> float: ... - @staticmethod - def getsizeof(value: _VT) -> float: ... - -class FIFOCache(Cache[_KT, _VT]): ... -class LFUCache(Cache[_KT, _VT]): ... -class LRUCache(Cache[_KT, _VT]): ... - -class RRCache(Cache[_KT, _VT]): - def __init__( - self, - maxsize: float, - choice: Callable[[Sequence[_KT]], _KT] = random.choice, - getsizeof: Callable[[_VT], float] | None = None, - ) -> None: ... - @property - def choice(self) -> Callable[[Sequence[_KT]], _KT]: ... - -class _TimedCache(Cache[_KT, _VT], Generic[_KT, _VT, _TT]): - def __init__(self, maxsize: float, timer: Callable[[], _TT], getsizeof: Callable[[_VT], float] | None = None) -> None: ... - - class _Timer(AbstractContextManager[_T]): - def __init__(self, timer: Callable[[], _T]) -> None: ... - def __call__(self) -> _T: ... - def __enter__(self) -> _T: ... - def __exit__(self, *exc: object) -> None: ... - def __getattr__(self, name: str) -> Any: ... - - @property - def timer(self) -> _Timer[_TT]: ... - -class TTLCache(_TimedCache[_KT, _VT, _TT]): - @overload - def __init__( - self: TTLCache[_KT2, _VT2, float], maxsize: float, ttl: float, *, getsizeof: Callable[[_VT2], float] | None = None - ) -> None: ... - @overload - def __init__( - self, - maxsize: float, - ttl: Any, # FIXME: must be "addable" to _TT - timer: Callable[[], _TT], - getsizeof: Callable[[_VT], float] | None = None, - ) -> None: ... - - @property - def ttl(self) -> Any: ... - def expire(self, time: _TT | None = None) -> list[tuple[_KT, _VT]]: ... - -class TLRUCache(_TimedCache[_KT, _VT, _TT]): - @overload - def __init__( - self: TLRUCache[_KT2, _VT2, float], - maxsize: float, - ttu: Callable[[_KT2, _VT2, float], float], - *, - getsizeof: Callable[[_VT2], float] | None = None, - ) -> None: ... - @overload - def __init__( - self, - maxsize: float, - ttu: Callable[[_KT, _VT, _TT], _TT], - timer: Callable[[], _TT], - getsizeof: Callable[[_VT], float] | None = None, - ) -> None: ... - - @property - def ttu(self) -> Callable[[_KT, _VT, _TT], _TT]: ... - def expire(self, time: _TT | None = None) -> list[tuple[_KT, _VT]]: ... - -class _CacheInfo(NamedTuple): - hits: int - misses: int - maxsize: float | None - currsize: float - -@type_check_only -class _AbstractCondition(AbstractContextManager[Any], Protocol): - def wait(self, timeout: float | None = None) -> bool: ... - def wait_for(self, predicate: Callable[[], _T], timeout: float | None = None) -> _T: ... - def notify(self, n: int = 1) -> None: ... - def notify_all(self) -> None: ... - -@type_check_only -class _cached_wrapper(Generic[_R]): - __wrapped__: Callable[..., _R] - __name__: str - __doc__: str | None - cache: MutableMapping[Any, Any] | None - cache_key: Callable[..., Any] = ... - cache_lock: AbstractContextManager[Any] | None = None - cache_condition: _AbstractCondition | None = None - def __call__(self, /, *args: Any, **kwargs: Any) -> _R: ... - def cache_clear(self) -> None: ... - -@type_check_only -class _cached_wrapper_info(_cached_wrapper[_R]): - def cache_info(self) -> _CacheInfo: ... - -@overload -def cached( - cache: MutableMapping[_KT, Any] | None, - key: Callable[..., _KT] = ..., - lock: AbstractContextManager[Any] | None = None, - condition: _AbstractCondition | None = None, - info: Literal[True] = ..., -) -> Callable[[Callable[..., _R]], _cached_wrapper_info[_R]]: ... -@overload -def cached( - cache: MutableMapping[_KT, Any] | None, - key: Callable[..., _KT] = ..., - lock: AbstractContextManager[Any] | None = None, - condition: _AbstractCondition | None = None, - info: Literal[False] = ..., -) -> Callable[[Callable[..., _R]], _cached_wrapper[_R]]: ... - -@type_check_only -class _cachedmethod_wrapper(Generic[_R]): - __wrapped__: Callable[..., _R] - __name__: str - __doc__: str | None - cache: MutableMapping[Any, Any] | None - cache_key: Callable[..., Any] = ... - cache_lock: AbstractContextManager[Any] | None = None - cache_condition: _AbstractCondition | None = None - def __call__(self, /, *args: Any, **kwargs: Any) -> _R: ... - def cache_clear(self) -> None: ... - -@type_check_only -class _cachedmethod_wrapper_info(_cachedmethod_wrapper[_R]): - def cache_info(self) -> _CacheInfo: ... - -@overload -def cachedmethod( - cache: Callable[[Any], MutableMapping[_KT, Any]], - key: Callable[..., _KT] = ..., - lock: Callable[[Any], AbstractContextManager[Any]] | None = None, - condition: Callable[[Any], _AbstractCondition] | None = None, - info: Literal[True] = ..., -) -> Callable[[Callable[..., _R]], _cachedmethod_wrapper_info[_R]]: ... -@overload -def cachedmethod( - cache: Callable[[Any], MutableMapping[_KT, Any]], - key: Callable[..., _KT] = ..., - lock: Callable[[Any], AbstractContextManager[Any]] | None = None, - condition: Callable[[Any], _AbstractCondition] | None = None, - info: Literal[False] = ..., -) -> Callable[[Callable[..., _R]], _cachedmethod_wrapper[_R]]: ... diff --git a/stubs/cachetools/cachetools/func.pyi b/stubs/cachetools/cachetools/func.pyi deleted file mode 100644 index 974dde3da37d..000000000000 --- a/stubs/cachetools/cachetools/func.pyi +++ /dev/null @@ -1,54 +0,0 @@ -from collections.abc import Callable, Sequence -from typing import Any, Final, Generic, TypeVar, overload, type_check_only - -from . import _CacheInfo - -__all__: Final = ("fifo_cache", "lfu_cache", "lru_cache", "rr_cache", "ttl_cache") - -_T = TypeVar("_T") -_R = TypeVar("_R") - -@type_check_only -class _cachetools_cache_wrapper(Generic[_R]): - __wrapped__: Callable[..., _R] - __name__: str - __doc__: str | None - def __call__(self, /, *args: Any, **kwargs: Any) -> _R: ... - def cache_info(self) -> _CacheInfo: ... - def cache_clear(self) -> None: ... - def cache_parameters(self) -> dict[str, Any]: ... - -@overload -def fifo_cache( - maxsize: int | None = 128, typed: bool = False -) -> Callable[[Callable[..., _R]], _cachetools_cache_wrapper[_R]]: ... -@overload -def fifo_cache(maxsize: Callable[..., _R], typed: bool = False) -> _cachetools_cache_wrapper[_R]: ... - -@overload -def lfu_cache(maxsize: int | None = 128, typed: bool = False) -> Callable[[Callable[..., _R]], _cachetools_cache_wrapper[_R]]: ... -@overload -def lfu_cache(maxsize: Callable[..., _R], typed: bool = False) -> _cachetools_cache_wrapper[_R]: ... - -@overload -def lru_cache(maxsize: int | None = 128, typed: bool = False) -> Callable[[Callable[..., _R]], _cachetools_cache_wrapper[_R]]: ... -@overload -def lru_cache(maxsize: Callable[..., _R], typed: bool = False) -> _cachetools_cache_wrapper[_R]: ... - -@overload -def rr_cache( - maxsize: int | None = 128, choice: Callable[[Sequence[_T]], _T] = ..., typed: bool = False -) -> Callable[[Callable[..., _R]], _cachetools_cache_wrapper[_R]]: ... -@overload -def rr_cache( - maxsize: Callable[..., _R], choice: Callable[[Sequence[_T]], _T] = ..., typed: bool = False -) -> _cachetools_cache_wrapper[_R]: ... - -@overload -def ttl_cache( - maxsize: int | None = 128, ttl: Any = 600, timer: Callable[[], _T] = ..., typed: bool = False -) -> Callable[[Callable[..., _R]], _cachetools_cache_wrapper[_R]]: ... -@overload -def ttl_cache( - maxsize: Callable[..., _R], ttl: Any = 600, timer: Callable[[], _T] = ..., typed: bool = False -) -> _cachetools_cache_wrapper[_R]: ... diff --git a/stubs/cachetools/cachetools/keys.pyi b/stubs/cachetools/cachetools/keys.pyi deleted file mode 100644 index feccf6f9bcea..000000000000 --- a/stubs/cachetools/cachetools/keys.pyi +++ /dev/null @@ -1,10 +0,0 @@ -from _typeshed import Unused -from collections.abc import Hashable -from typing import Final - -__all__: Final = ("hashkey", "methodkey", "typedkey", "typedmethodkey") - -def hashkey(*args: Hashable, **kwargs: Hashable) -> tuple[Hashable, ...]: ... -def methodkey(self: Unused, /, *args: Hashable, **kwargs: Hashable) -> tuple[Hashable, ...]: ... -def typedkey(*args: Hashable, **kwargs: Hashable) -> tuple[Hashable, ...]: ... -def typedmethodkey(self: Unused, /, *args: Hashable, **kwargs: Hashable) -> tuple[Hashable, ...]: ...