Add functools.cached_property (#3439)

Part of #3319
This commit is contained in:
Sebastian Rittau
2019-11-06 16:21:32 +01:00
committed by Jelle Zijlstra
parent f39c102eb8
commit add0b5e930

View File

@@ -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: ...