mirror of
https://github.com/astral-sh/ruff.git
synced 2025-10-05 16:10:36 +00:00
![]() fix https://github.com/astral-sh/ty/issues/943 ## Summary Add module-level `__getattr__` support for ty's type checker, fixing issue https://github.com/astral-sh/ty/issues/943. Module-level `__getattr__` functions ([PEP 562](https://peps.python.org/pep-0562/)) are now respected when resolving dynamic attributes, matching the behavior of mypy and pyright. ## Implementation Thanks @sharkdp for the guidance in https://github.com/astral-sh/ty/issues/943#issuecomment-3157566579 - Adds module-specific `__getattr__` resolution in `ModuleLiteral.static_member()` - Maintains proper attribute precedence: explicit attributes > submodules > `__getattr__` ## Test Plan - New mdtest covering basic functionality, type annotations, attribute precedence, and edge cases (run ```cargo nextest run -p ty_python_semantic mdtest__import_module_getattr```) - All new tests pass, verifying `__getattr__` is called correctly and returns proper types - Existing test suite passes, ensuring no regressions introduced |
||
---|---|---|
.. | ||
basic.md | ||
builtins.md | ||
case_sensitive.md | ||
conditional.md | ||
conflicts.md | ||
conventions.md | ||
cyclic.md | ||
dunder_all.md | ||
errors.md | ||
invalid_syntax.md | ||
module_getattr.md | ||
namespace.md | ||
relative.md | ||
site_packages_discovery.md | ||
star.md | ||
stub_packages.md | ||
stubs.md | ||
tracking.md |