|
| 1 | +from ._typing import AC, Protocol, R as R, TypedDict |
| 2 | +from typing import ( |
| 3 | + Any, |
| 4 | + Awaitable, |
| 5 | + Callable, |
| 6 | + NamedTuple, |
| 7 | + Optional, |
| 8 | + overload, |
| 9 | +) |
| 10 | + |
| 11 | +class CacheInfo(NamedTuple): |
| 12 | + hits: int |
| 13 | + misses: int |
| 14 | + maxsize: Optional[int] |
| 15 | + currsize: int |
| 16 | + |
| 17 | +class CacheParameters(TypedDict): |
| 18 | + maxsize: Optional[int] |
| 19 | + typed: bool |
| 20 | + |
| 21 | +class LRUAsyncCallable(Protocol[AC]): |
| 22 | + __call__: AC |
| 23 | + @overload |
| 24 | + def __get__( |
| 25 | + self: LRUAsyncCallable[AC], |
| 26 | + instance: None, |
| 27 | + owner: Optional[type] = ..., |
| 28 | + ) -> LRUAsyncCallable[AC]: ... |
| 29 | + @overload |
| 30 | + def __get__( |
| 31 | + self: LRUAsyncCallable[Callable[..., Awaitable[R]]], |
| 32 | + instance: object, |
| 33 | + owner: Optional[type] = ..., |
| 34 | + ) -> LRUAsyncBoundCallable[Callable[..., Awaitable[R]]]: ... |
| 35 | + @property |
| 36 | + def __wrapped__(self) -> AC: ... |
| 37 | + def cache_parameters(self) -> CacheParameters: ... |
| 38 | + def cache_info(self) -> CacheInfo: ... |
| 39 | + def cache_clear(self) -> None: ... |
| 40 | + def cache_discard(self, *args: Any, **kwargs: Any) -> None: ... |
| 41 | + |
| 42 | +class LRUAsyncBoundCallable(LRUAsyncCallable[AC]): |
| 43 | + __self__: object |
| 44 | + __call__: AC |
| 45 | + def __get__( |
| 46 | + self: LRUAsyncBoundCallable[AC], |
| 47 | + instance: Any, |
| 48 | + owner: Optional[type] = ..., |
| 49 | + ) -> LRUAsyncBoundCallable[AC]: ... |
| 50 | + def __init__(self, lru: LRUAsyncCallable[AC], __self__: object) -> None: ... |
| 51 | + @property |
| 52 | + def __wrapped__(self) -> AC: ... |
| 53 | + @property |
| 54 | + def __func__(self) -> LRUAsyncCallable[AC]: ... |
| 55 | + |
| 56 | +@overload |
| 57 | +def lru_cache(maxsize: AC, typed: bool = ...) -> LRUAsyncCallable[AC]: ... |
| 58 | +@overload |
| 59 | +def lru_cache( |
| 60 | + maxsize: Optional[int] = ..., typed: bool = ... |
| 61 | +) -> Callable[[AC], LRUAsyncCallable[AC]]: ... |
0 commit comments