From add0b5e930a1db16560fde45a3b710eefc625709 Mon Sep 17 00:00:00 2001 From: Sebastian Rittau Date: Wed, 6 Nov 2019 16:21:32 +0100 Subject: [PATCH] Add functools.cached_property (#3439) Part of #3319 --- stdlib/3/functools.pyi | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/stdlib/3/functools.pyi b/stdlib/3/functools.pyi index 78a3466ea..a23ef6f5f 100644 --- a/stdlib/3/functools.pyi +++ b/stdlib/3/functools.pyi @@ -76,3 +76,14 @@ class _SingleDispatchCallable(Generic[_T]): def __call__(self, *args: Any, **kwargs: Any) -> _T: ... def singledispatch(func: Callable[..., _T]) -> _SingleDispatchCallable[_T]: ... + +if sys.version_info >= (3, 8): + class cached_property(Generic[_S, _T]): + func: Callable[[_S], _T] + attrname: Optional[str] + def __init__(self, func: Callable[[_S], _T]) -> None: ... + @overload + def __get__(self, instance: None, owner: Optional[Type[_S]] = ...) -> cached_property[_S, _T]: ... + @overload + def __get__(self, instance: _S, owner: Optional[Type[_S]] = ...) -> _T: ... + def __set_name__(self, owner: Type[_S], name: str) -> None: ...