Make return type of functools.cache_property covariant (#10053)

Co-authored-by: Jelle Zijlstra <jelle.zijlstra@gmail.com>
This commit is contained in:
Nikita SobolevandJelle Zijlstra authored and GitHub committed 2024-02-17 15:38:46 -08:00
1 parent 3fa6374c9a
commit 863d22a239
2 files changed
+25 -5

No files matched your search

+19
View File
@@ -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()