mirror of
https://github.com/astral-sh/ruff.git
synced 2025-10-04 23:50:31 +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 |
||
---|---|---|
.. | ||
resources | ||
src | ||
tests | ||
build.rs | ||
Cargo.toml | ||
mdtest.py | ||
mdtest.py.lock |