mirror of
https://github.com/davidhalter/typeshed.git
synced 2025-12-10 05:51:52 +08:00
cachetools.Cache sizes are numerics (#5440)
replace int with float for cachesize
This commit is contained in:
@@ -6,15 +6,15 @@ _KT = TypeVar("_KT")
|
||||
_VT = TypeVar("_VT")
|
||||
|
||||
class Cache(DefaultMapping[_KT, _VT], Generic[_KT, _VT]):
|
||||
def __init__(self, maxsize: int, getsizeof: Optional[Callable[[_VT], int]] = ...) -> None: ...
|
||||
def __init__(self, maxsize: float, getsizeof: Optional[Callable[[_VT], float]] = ...) -> 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) -> int: ...
|
||||
def maxsize(self) -> float: ...
|
||||
@property
|
||||
def currsize(self) -> int: ...
|
||||
def currsize(self) -> float: ...
|
||||
@staticmethod
|
||||
def getsizeof(value: _VT) -> int: ...
|
||||
def getsizeof(value: _VT) -> float: ...
|
||||
|
||||
@@ -5,7 +5,7 @@ _T = TypeVar("_T")
|
||||
_F = TypeVar("_F", bound=Callable[..., Any])
|
||||
_RET = Callable[[_F], _F]
|
||||
|
||||
def lfu_cache(maxsize: int = ..., typed: bool = ...) -> _RET[_F]: ...
|
||||
def lru_cache(maxsize: int = ..., typed: bool = ...) -> _RET[_F]: ...
|
||||
def rr_cache(maxsize: int = ..., choice: Optional[Callable[[Sequence[_T]], _T]] = ..., typed: bool = ...) -> _RET[_F]: ...
|
||||
def ttl_cache(maxsize: int = ..., ttl: float = ..., timer: float = ..., typed: bool = ...) -> _RET[_F]: ...
|
||||
def lfu_cache(maxsize: float = ..., typed: bool = ...) -> _RET[_F]: ...
|
||||
def lru_cache(maxsize: float = ..., typed: bool = ...) -> _RET[_F]: ...
|
||||
def rr_cache(maxsize: float = ..., choice: Optional[Callable[[Sequence[_T]], _T]] = ..., typed: bool = ...) -> _RET[_F]: ...
|
||||
def ttl_cache(maxsize: float = ..., ttl: float = ..., timer: float = ..., typed: bool = ...) -> _RET[_F]: ...
|
||||
|
||||
@@ -6,7 +6,7 @@ _KT = TypeVar("_KT")
|
||||
_VT = TypeVar("_VT")
|
||||
|
||||
class LFUCache(Cache[_KT, _VT]):
|
||||
def __init__(self, maxsize: int, getsizeof: Optional[Callable[[_VT], int]] = ...) -> None: ...
|
||||
def __init__(self, maxsize: float, getsizeof: Optional[Callable[[_VT], float]] = ...) -> 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: ...
|
||||
|
||||
@@ -6,7 +6,7 @@ _KT = TypeVar("_KT")
|
||||
_VT = TypeVar("_VT")
|
||||
|
||||
class LRUCache(Cache[_KT, _VT]):
|
||||
def __init__(self, maxsize: int, getsizeof: Optional[Callable[[_VT], int]] = ...) -> None: ...
|
||||
def __init__(self, maxsize: float, getsizeof: Optional[Callable[[_VT], float]] = ...) -> 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: ...
|
||||
|
||||
@@ -8,9 +8,9 @@ _VT = TypeVar("_VT")
|
||||
class RRCache(Cache[_KT, _VT]):
|
||||
def __init__(
|
||||
self,
|
||||
maxsize: int,
|
||||
maxsize: float,
|
||||
choice: Optional[Callable[[Sequence[_KT]], _KT]] = ...,
|
||||
getsizeof: Optional[Callable[[_VT], int]] = ...,
|
||||
getsizeof: Optional[Callable[[_VT], float]] = ...,
|
||||
) -> None: ...
|
||||
def __getitem__(self, key: _KT) -> _VT: ...
|
||||
def __setitem__(self, key: _KT, value: _VT) -> None: ...
|
||||
|
||||
@@ -1,13 +1,13 @@
|
||||
from typing import Callable, Iterator, Optional, TypeVar
|
||||
|
||||
from .cache import Cache
|
||||
from .cache import Cache as Cache
|
||||
|
||||
_KT = TypeVar("_KT")
|
||||
_VT = TypeVar("_VT")
|
||||
|
||||
class TTLCache(Cache[_KT, _VT]):
|
||||
def __init__(
|
||||
self, maxsize: int, ttl: float, timer: Callable[[], float] = ..., getsizeof: Optional[Callable[[_VT], int]] = ...
|
||||
self, maxsize: float, ttl: float, timer: Callable[[], float] = ..., getsizeof: Optional[Callable[[_VT], float]] = ...
|
||||
) -> 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: ...
|
||||
@@ -15,7 +15,7 @@ class TTLCache(Cache[_KT, _VT]):
|
||||
def __iter__(self) -> Iterator[_KT]: ...
|
||||
def __len__(self) -> int: ...
|
||||
@property
|
||||
def currsize(self) -> int: ...
|
||||
def currsize(self) -> float: ...
|
||||
@property
|
||||
def timer(self) -> Callable[[], float]: ...
|
||||
@property
|
||||
|
||||
Reference in New Issue
Block a user