[ty] Bypass member lookup for module imports by charliermarsh · Pull Request #25723 · astral-sh/ruff (original) (raw)
Summary
from module import name import inference already knows that the left-hand side resolved to a module literal, but it still routed the final attribute lookup through the generic Type::member path. That path handles arbitrary receiver types and descriptor behavior before eventually reaching module lookup.
This constructs the ModuleLiteralType directly, reuses it for the existing self-referential global-import guard, and calls ModuleLiteralType::static_member when checking whether the imported module exports the requested name. Import semantics stay the same, while module import lookup avoids the generic member-lookup machinery.
The now-unused Type::as_module_literal helper is removed.