Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 13 additions & 1 deletion stdlib/@tests/test_cases/check_functools.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
from __future__ import annotations

from functools import cached_property, wraps
from functools import cache, cached_property, wraps
from typing import Callable, TypeVar
from typing_extensions import ParamSpec, assert_type

Expand Down Expand Up @@ -96,3 +96,15 @@ class Y(X):
@cached_property
def some(self) -> Child: # safe override
return Child()


class CachedParent:
@cache
def method(self) -> Parent:
return Parent()


class CachedChild(CachedParent):
@cache
def method(self) -> Child:
return Child()
10 changes: 5 additions & 5 deletions stdlib/functools.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -54,14 +54,14 @@ class _CacheParameters(TypedDict):
typed: bool

@final
class _lru_cache_wrapper(Generic[_T]):
__wrapped__: Callable[..., _T]
def __call__(self, *args: Hashable, **kwargs: Hashable) -> _T: ...
class _lru_cache_wrapper(Generic[_T_co]):
__wrapped__: Callable[..., _T_co]
def __call__(self, *args: Hashable, **kwargs: Hashable) -> _T_co: ...
def cache_info(self) -> _CacheInfo: ...
def cache_clear(self) -> None: ...
def cache_parameters(self) -> _CacheParameters: ...
def __copy__(self) -> _lru_cache_wrapper[_T]: ...
def __deepcopy__(self, memo: Any, /) -> _lru_cache_wrapper[_T]: ...
def __copy__(self) -> _lru_cache_wrapper[_T_co]: ...
def __deepcopy__(self, memo: Any, /) -> _lru_cache_wrapper[_T_co]: ...

@overload
def lru_cache(maxsize: int | None = 128, typed: bool = False) -> Callable[[Callable[..., _T]], _lru_cache_wrapper[_T]]: ...
Expand Down