Summary
Noticed this while messing around with astral-sh/ruff#22111. If you have a name from a different module also defined in the current module, inserting an inlay hint can cause a name collision.
https://play.ty.dev/9a2adb45-8117-49eb-9825-f659ed33ab32
module.py:
main.py:
from dataclasses import dataclass
import module # Don't import A directly because there's also an A here
class A: ...
@dataclass
class B[T]:
x: T
b = B(module.A())
# After inserting, oops
# Object of type `B[module.A]` is not assignable to `B[main.A]`
b: B[A] = B(module.A())
This is most common for me with Literal, since sometimes I do just want a Literal in my parser, but could happen with any name.
Version
playground 8a0426676
Summary
Noticed this while messing around with astral-sh/ruff#22111. If you have a name from a different module also defined in the current module, inserting an inlay hint can cause a name collision.
https://play.ty.dev/9a2adb45-8117-49eb-9825-f659ed33ab32
module.py:main.py:This is most common for me with
Literal, since sometimes I do just want aLiteralin my parser, but could happen with any name.Version
playground 8a0426676