Closed
Description
When mypy 0.740 is run on the following code:
class C:
@property
def prop(self) -> int:
return 123
c = C()
print(c.prop)
getter = C.prop.__get__
print(getter(c))
It reports:
8: error: "Callable[[C], int]" has no attribute "__get__"
I think the problem is that, in general, mypy assumes decorators don't change the signature of the decorated function. When I ask it to reveal the type of C.prop
, it reports def (self: testcase.C) -> builtins.int
, which is the signature of the undecorated function, not of the property.
Since the property
decorator is a built-in, it would be useful to have dedicated support for it in mypy.
Metadata
Metadata
Assignees
Labels
No labels