Bug report
Bug description:
I played around with __annotations__
, and noticed that it returns an incorrect result when a type is defined both inside and outside the class scope: [mypy-playground]
class Bar: ...
class Foo:
x: Bar = Bar()
class Bar: ...
y: Bar = Bar()
reveal_type(Foo.x) # __main__.Bar
reveal_type(Foo.y) # __main__.Foo.Bar
assert isinstance(Foo.x, Bar) # ✅
assert isinstance(Foo.y, Foo.Bar) # ✅
However, Foo.__annotations__
returns {'x': <class '__main__.Foo.Bar'>, 'y': <class '__main__.Foo.Bar'>}
CPython versions tested on:
3.14.0~a2 from deadsnakes PPA
Operating systems tested on:
Linux