Closed
Description
Consider this example:
class X:
__slots__ = ('a',)
a: int
print(X.a) # <member 'a' of 'X' objects>
reveal_type(X.a) # builtins.int
reveal_type(X.a.__get__) # Any
# "int" has no attribute "__get__"; maybe "__gt__", "__ge__", or "__ne__"?
I expect to get member_descriptor
and some Callable
, but instead i see two wrong reveals and one error.
I can use this bug to write unsafe code:
class X:
__slots__ = ('a',)
a: int
x = X()
x.a = X.a # no error!
assert isinstance(x.a, int), x.a
# AssertionError: <member 'a' of 'X' objects>
My Environment
mypy 0.961 (compiled: no)
- no command-line flags, no config file
CPython 3.10.4
- Windows 10