mirror of
https://github.com/davidhalter/typeshed.git
synced 2025-12-20 10:51:15 +08:00
Make return type of functools.cache_property covariant (#10053)
Co-authored-by: Jelle Zijlstra <jelle.zijlstra@gmail.com>
This commit is contained in:
@@ -46,3 +46,22 @@ def check_cached_property_settable(x: int) -> None:
|
||||
assert_type(b.x, int)
|
||||
b.x = x
|
||||
assert_type(b.x, int)
|
||||
|
||||
|
||||
# https://github.com/python/typeshed/issues/10048
|
||||
class Parent: ...
|
||||
|
||||
|
||||
class Child(Parent): ...
|
||||
|
||||
|
||||
class X:
|
||||
@cached_property
|
||||
def some(self) -> Parent:
|
||||
return Parent()
|
||||
|
||||
|
||||
class Y(X):
|
||||
@cached_property
|
||||
def some(self) -> Child: # safe override
|
||||
return Child()
|
||||
|
||||
Reference in New Issue
Block a user