Copy cached_property return type annotations to __annotations__
This commit is contained in:
parent
f3a5b7ada0
commit
b67c936b27
|
@ -1191,6 +1191,18 @@ class cached_property:
|
|||
f"({self.attrname!r} and {name!r})."
|
||||
)
|
||||
|
||||
# copy across the annotation for runtime introspection
|
||||
try:
|
||||
prop_ann = self.fget.__annotations__['return']
|
||||
except KeyError:
|
||||
return
|
||||
|
||||
try:
|
||||
owner_anns = owner.__annotations__
|
||||
except AttributeError:
|
||||
owner_anns = owner.__annotations__ = {}
|
||||
owner_anns[name] = prop_ann
|
||||
|
||||
def __get__(self, instance, owner=None):
|
||||
if instance is None:
|
||||
return self
|
||||
|
|
Loading…
Reference in New Issue