Skip to content

Commit 3e926dd

Browse files
pre-commit-ci[bot]tkem
authored andcommitted
[pre-commit.ci] auto fixes from pre-commit.com hooks
1 parent 8abfe5d commit 3e926dd

File tree

2 files changed

+31
-14
lines changed

2 files changed

+31
-14
lines changed

stubs/cachetools/@tests/stubtest_allowlist.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@ cachetools.LFUCache.__setitem__
99
cachetools.LRUCache.__delitem__
1010
cachetools.LRUCache.__getitem__
1111
cachetools.LRUCache.__setitem__
12+
cachetools.RRCache.__delitem__
13+
cachetools.RRCache.__setitem__
1214
cachetools.TLRUCache.__delitem__
1315
cachetools.TLRUCache.__getitem__
1416
cachetools.TLRUCache.__setitem__

stubs/cachetools/cachetools/__init__.pyi

Lines changed: 29 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,6 @@
11
from collections.abc import Callable, Iterator, MutableMapping, Sequence
22
from contextlib import AbstractContextManager
33
from typing import Any, Final, Generic, Literal, NamedTuple, Protocol, TypeVar, overload, type_check_only
4-
from typing_extensions import Self
5-
6-
from . import keys
74

85
__all__: Final = ("Cache", "FIFOCache", "LFUCache", "LRUCache", "RRCache", "TLRUCache", "TTLCache", "cached", "cachedmethod")
96
__version__: str
@@ -53,10 +50,18 @@ class RRCache(Cache[_KT, _VT]):
5350
def choice(self) -> Callable[[Sequence[_KT]], _KT]: ...
5451

5552
class _TimedCache(Cache[_KT, _VT]):
56-
def __init__(self, maxsize: float, timer: Callable[..., _TT], getsizeof: Callable[[_VT], float] | None): ...
53+
@overload
54+
def __init__(self, maxsize: float, timer: Callable[[], _TT] = ..., getsizeof: None = None): ...
55+
@overload
56+
def __init__(self, maxsize: float, timer: Callable[[], _TT], getsizeof: Callable[[_VT], float]): ...
57+
@overload
58+
def __init__(self, maxsize: float, timer: Callable[[], _TT] = ..., *, getsizeof: Callable[[_VT], float]): ...
5759

58-
class _Timer(AbstractContextManager[_TT]):
59-
def __call__(self) -> _TT: ...
60+
class _Timer:
61+
def __init__(self, timer: Callable[[], _TT]) -> None: ...
62+
def __call__(self) -> Any: ...
63+
def __enter__(self) -> Any: ...
64+
def __exit__(self, *exc: object) -> None: ...
6065
def __getattr__(self, name: str) -> Any: ...
6166

6267
@property
@@ -71,18 +76,29 @@ class TTLCache(_TimedCache[_KT, _VT]):
7176
def __init__(self, maxsize: float, ttl: Any, timer: Callable[..., _TT] = ..., *, getsizeof: Callable[[_VT], float]): ...
7277
@property
7378
def ttl(self) -> Any: ...
74-
def expire(self, time: _TT | None = None) -> list[tuple[_KT, _VT]]: ...
79+
def expire(self, time: Any | None = None) -> list[tuple[_KT, _VT]]: ...
7580

7681
class TLRUCache(_TimedCache[_KT, _VT]):
7782
@overload
78-
def __init__(self, maxsize: float, ttu: Callable[[_KT, _VT, _TT], _TT], timer: Callable[..., _TT] = ..., getsizeof: None = None): ...
83+
def __init__(
84+
self, maxsize: float, ttu: Callable[[_KT, _VT, _TT], _TT], timer: Callable[..., _TT] = ..., getsizeof: None = None
85+
): ...
7986
@overload
80-
def __init__(self, maxsize: float, ttu: Callable[[_KT, _VT, _TT], _TT], timer: Callable[..., _TT], getsizeof: Callable[[_VT], float]): ...
87+
def __init__(
88+
self, maxsize: float, ttu: Callable[[_KT, _VT, _TT], _TT], timer: Callable[..., _TT], getsizeof: Callable[[_VT], float]
89+
): ...
8190
@overload
82-
def __init__(self, maxsize: float, ttu: Callable[[_KT, _VT, _TT], _TT], timer: Callable[..., _TT] = ..., *, getsizeof: Callable[[_VT], float]): ...
91+
def __init__(
92+
self,
93+
maxsize: float,
94+
ttu: Callable[[_KT, _VT, _TT], _TT],
95+
timer: Callable[..., _TT] = ...,
96+
*,
97+
getsizeof: Callable[[_VT], float],
98+
): ...
8399
@property
84100
def ttu(self) -> Callable[[_KT, _VT, _TT], _TT]: ...
85-
def expire(self, time: _TT | None = None) -> list[tuple[_KT, _VT]]: ...
101+
def expire(self, time: Any | None = None) -> list[tuple[_KT, _VT]]: ...
86102

87103
class _CacheInfo(NamedTuple):
88104
hits: int
@@ -92,9 +108,9 @@ class _CacheInfo(NamedTuple):
92108

93109
@type_check_only
94110
class _AbstractCondition(AbstractContextManager[Any], Protocol):
95-
#def wait(self, timeout: float | None = None) -> bool: ...
111+
# def wait(self, timeout: float | None = None) -> bool: ...
96112
def wait_for(self, predicate: Callable[[], _T], timeout: float | None = None) -> _T: ...
97-
#def notify(self, n: int = 1) -> None: ...
113+
# def notify(self, n: int = 1) -> None: ...
98114
def notify_all(self) -> None: ...
99115

100116
@type_check_only
@@ -129,7 +145,6 @@ def cached(
129145
condition: _AbstractCondition | None = None,
130146
info: Literal[False] = ...,
131147
) -> Callable[[Callable[..., _R]], _cached_wrapper[_R]]: ...
132-
133148
@type_check_only
134149
class _cachedmethod_wrapper(Generic[_R]):
135150
__wrapped__: Callable[..., _R]

0 commit comments

Comments
 (0)