functools: remove first type param of cached_property (#3553)

Fixes #3547

This removes some type safety in exceptional cases, like code that interacts
directly with cached_property objects, but that seems like a price worth
paying.
This commit is contained in:
Jelle Zijlstra
2019-12-21 10:42:43 -08:00
committed by GitHub
parent e404e1592d
commit 5021b30711

View File

@@ -78,12 +78,12 @@ class _SingleDispatchCallable(Generic[_T]):
def singledispatch(func: Callable[..., _T]) -> _SingleDispatchCallable[_T]: ...
if sys.version_info >= (3, 8):
class cached_property(Generic[_S, _T]):
func: Callable[[_S], _T]
class cached_property(Generic[_T]):
func: Callable[[Any], _T]
attrname: Optional[str]
def __init__(self, func: Callable[[_S], _T]) -> None: ...
def __init__(self, func: Callable[[Any], _T]) -> None: ...
@overload
def __get__(self, instance: None, owner: Optional[Type[_S]] = ...) -> cached_property[_S, _T]: ...
def __get__(self, instance: None, owner: Optional[Type[Any]] = ...) -> cached_property[_T]: ...
@overload
def __get__(self, instance: _S, owner: Optional[Type[_S]] = ...) -> _T: ...
def __set_name__(self, owner: Type[_S], name: str) -> None: ...
def __get__(self, instance: _S, owner: Optional[Type[Any]] = ...) -> _T: ...
def __set_name__(self, owner: Type[Any], name: str) -> None: ...