cachetools: Fix invalid TypeVar usage (#8073)

This commit is contained in:
Alex Waygood
2022-06-14 14:39:45 +01:00
committed by GitHub
parent 199132122b
commit 7de1ed9589

View File

@@ -11,7 +11,10 @@ _VT = TypeVar("_VT")
_T = TypeVar("_T")
class Cache(MutableMapping[_KT, _VT], Generic[_KT, _VT]):
def __init__(self, maxsize: float, getsizeof: Callable[[_VT], float] | None = ...) -> None: ...
@overload
def __init__(self, maxsize: float, getsizeof: Callable[[_VT], float]) -> None: ...
@overload
def __init__(self, maxsize: float, getsizeof: None = ...) -> None: ...
def __getitem__(self, key: _KT) -> _VT: ...
def __setitem__(self, key: _KT, value: _VT) -> None: ...
def __delitem__(self, key: _KT) -> None: ...
@@ -30,29 +33,32 @@ class Cache(MutableMapping[_KT, _VT], Generic[_KT, _VT]):
@staticmethod
def getsizeof(value: _VT) -> float: ...
class FIFOCache(Cache[_KT, _VT]):
def __init__(self, maxsize: float, getsizeof: Callable[[_VT], float] | None = ...) -> None: ...
class LFUCache(Cache[_KT, _VT]):
def __init__(self, maxsize: float, getsizeof: Callable[[_VT], float] | None = ...) -> None: ...
class LRUCache(Cache[_KT, _VT]):
def __init__(self, maxsize: float, getsizeof: Callable[[_VT], float] | None = ...) -> None: ...
class MRUCache(Cache[_KT, _VT]):
def __init__(self, maxsize: float, getsizeof: Callable[[_VT], float] | None = ...) -> None: ...
class FIFOCache(Cache[_KT, _VT]): ...
class LFUCache(Cache[_KT, _VT]): ...
class LRUCache(Cache[_KT, _VT]): ...
class MRUCache(Cache[_KT, _VT]): ...
class RRCache(Cache[_KT, _VT]):
def __init__(
self, maxsize: float, choice: Callable[[Sequence[_KT]], _KT] | None = ..., getsizeof: Callable[[_VT], float] | None = ...
) -> None: ...
@overload
def __init__(self, maxsize: float, choice: None = ..., getsizeof: None = ...) -> None: ...
@overload
def __init__(self, maxsize: float, *, getsizeof: Callable[[_VT], float]) -> None: ...
@overload
def __init__(self, maxsize: float, choice: None, getsizeof: Callable[[_VT], float]) -> None: ...
@overload
def __init__(self, maxsize: float, choice: Callable[[Sequence[_KT]], _KT], getsizeof: None = ...) -> None: ...
@overload
def __init__(self, maxsize: float, choice: Callable[[Sequence[_KT]], _KT], getsizeof: Callable[[_VT], float]) -> None: ...
@property
def choice(self) -> Callable[[Sequence[_KT]], _KT]: ...
class _TimedCache(Cache[_KT, _VT]):
def __init__(
self, maxsize: float, timer: Callable[[], float] = ..., getsizeof: Callable[[_VT], float] | None = ...
) -> None: ...
@overload
def __init__(self, maxsize: float, timer: Callable[[], float] = ..., getsizeof: None = ...) -> None: ...
@overload
def __init__(self, maxsize: float, timer: Callable[[], float], getsizeof: Callable[[_VT], float]) -> None: ...
@overload
def __init__(self, maxsize: float, timer: Callable[[], float] = ..., *, getsizeof: Callable[[_VT], float]) -> None: ...
@property
def currsize(self) -> float: ...
@@ -66,8 +72,13 @@ class _TimedCache(Cache[_KT, _VT]):
def timer(self) -> _Timer: ...
class TTLCache(_TimedCache[_KT, _VT]):
@overload
def __init__(self, maxsize: float, ttl: float, timer: Callable[[], float] = ..., getsizeof: None = ...) -> None: ...
@overload
def __init__(self, maxsize: float, ttl: float, timer: Callable[[], float], getsizeof: Callable[[_VT], float]) -> None: ...
@overload
def __init__(
self, maxsize: float, ttl: float, timer: Callable[[], float] = ..., getsizeof: Callable[[_VT], float] | None = ...
self, maxsize: float, ttl: float, timer: Callable[[], float] = ..., *, getsizeof: Callable[[_VT], float]
) -> None: ...
@property
def ttl(self) -> float: ...