-
-
Notifications
You must be signed in to change notification settings - Fork 3k
Closed
Labels
Description
A descriptor is something with a __get__
method; the return type of __get__
defines the type of the corresponding instance attribute. However the corresponding class attribute ought to be inspectable just as if it was an instance of the descriptor class; right now it is treated as the same type as the instance attribute. Example:
class Descr:
def __get__(self, *args) -> int: pass
name: str = 'booh'
class C:
a = Descr()
reveal_type(C().a) # int
reveal_type(C.a.name) # Any # E: "int" has no attribute "name"