mirror of
https://github.com/davidhalter/typeshed.git
synced 2026-05-04 04:25:50 +08:00
[cachetools] Add @type_check_only to stub-only private classes (#15516)
Also unify duplicated `_CacheInfo` definitions
This commit is contained in:
@@ -2,7 +2,7 @@ from _typeshed import IdentityFunction, Unused
|
||||
from collections.abc import Callable, Iterator, MutableMapping, Sequence
|
||||
from contextlib import AbstractContextManager
|
||||
from threading import Condition
|
||||
from typing import Any, Generic, Literal, NamedTuple, TypeVar, overload
|
||||
from typing import Any, Generic, Literal, NamedTuple, TypeVar, overload, type_check_only
|
||||
from typing_extensions import Self, deprecated
|
||||
|
||||
__all__ = ("Cache", "FIFOCache", "LFUCache", "LRUCache", "RRCache", "TLRUCache", "TTLCache", "cached", "cachedmethod")
|
||||
@@ -106,10 +106,12 @@ class _CacheInfo(NamedTuple):
|
||||
maxsize: int | None
|
||||
currsize: int
|
||||
|
||||
@type_check_only
|
||||
class _cached_wrapper(Generic[_R]):
|
||||
__wrapped__: Callable[..., _R]
|
||||
def __call__(self, /, *args: Any, **kwargs: Any) -> _R: ...
|
||||
|
||||
@type_check_only
|
||||
class _cached_wrapper_info(_cached_wrapper[_R]):
|
||||
def cache_info(self) -> _CacheInfo: ...
|
||||
def cache_clear(self) -> None: ...
|
||||
|
||||
@@ -1,17 +1,14 @@
|
||||
from collections.abc import Callable, Sequence
|
||||
from typing import Any, Final, Generic, NamedTuple, TypeVar, overload
|
||||
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")
|
||||
|
||||
class _CacheInfo(NamedTuple):
|
||||
hits: int
|
||||
misses: int
|
||||
maxsize: int | None
|
||||
currsize: int
|
||||
|
||||
@type_check_only
|
||||
class _cachetools_cache_wrapper(Generic[_R]):
|
||||
__wrapped__: Callable[..., _R]
|
||||
def __call__(self, /, *args: Any, **kwargs: Any) -> _R: ...
|
||||
|
||||
Reference in New Issue
Block a user