Skip to content

Commit 9fb53ff

Browse files
committed
Use ParamSpec _lru_cache_wrapper
Closes: #11280
1 parent 67be89e commit 9fb53ff

File tree

1 file changed

+10
-8
lines changed

1 file changed

+10
-8
lines changed

stdlib/functools.pyi

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,9 @@ __all__ = [
2525

2626
_T = TypeVar("_T")
2727
_T_co = TypeVar("_T_co", covariant=True)
28+
_R = TypeVar("_R")
2829
_S = TypeVar("_S")
30+
_P = ParamSpec("_P")
2931
_PWrapped = ParamSpec("_PWrapped")
3032
_RWrapped = TypeVar("_RWrapped")
3133
_PWrapper = ParamSpec("_PWrapper")
@@ -54,19 +56,19 @@ class _CacheParameters(TypedDict):
5456
typed: bool
5557

5658
@final
57-
class _lru_cache_wrapper(Generic[_T]):
58-
__wrapped__: Callable[..., _T]
59-
def __call__(self, *args: Hashable, **kwargs: Hashable) -> _T: ...
59+
class _lru_cache_wrapper(Generic[_P, _R]):
60+
__wrapped__: Callable[_P, _R]
61+
def __call__(self, *args: _P.args, **kwargs: _P.kwargs) -> _R: ...
6062
def cache_info(self) -> _CacheInfo: ...
6163
def cache_clear(self) -> None: ...
6264
def cache_parameters(self) -> _CacheParameters: ...
63-
def __copy__(self) -> _lru_cache_wrapper[_T]: ...
64-
def __deepcopy__(self, memo: Any, /) -> _lru_cache_wrapper[_T]: ...
65+
def __copy__(self) -> _lru_cache_wrapper[_P, _R]: ...
66+
def __deepcopy__(self, memo: Any, /) -> _lru_cache_wrapper[_P, _R]: ...
6567

6668
@overload
67-
def lru_cache(maxsize: int | None = 128, typed: bool = False) -> Callable[[Callable[..., _T]], _lru_cache_wrapper[_T]]: ...
69+
def lru_cache(maxsize: int | None = 128, typed: bool = False) -> Callable[[Callable[_P, _R]], _lru_cache_wrapper[_P, _R]]: ...
6870
@overload
69-
def lru_cache(maxsize: Callable[..., _T], typed: bool = False) -> _lru_cache_wrapper[_T]: ...
71+
def lru_cache(maxsize: Callable[_P, _R], typed: bool = False) -> _lru_cache_wrapper[_P, _R]: ...
7072

7173
if sys.version_info >= (3, 14):
7274
WRAPPER_ASSIGNMENTS: Final[
@@ -237,7 +239,7 @@ class cached_property(Generic[_T_co]):
237239
def __set__(self, instance: object, value: _T_co) -> None: ... # type: ignore[misc] # pyright: ignore[reportGeneralTypeIssues]
238240
def __class_getitem__(cls, item: Any, /) -> GenericAlias: ...
239241

240-
def cache(user_function: Callable[..., _T], /) -> _lru_cache_wrapper[_T]: ...
242+
def cache(user_function: Callable[_P, _R], /) -> _lru_cache_wrapper[_P, _R]: ...
241243
def _make_key(
242244
args: tuple[Hashable, ...],
243245
kwds: SupportsItems[Any, Any],

0 commit comments

Comments
 (0)