mirror of
https://github.com/astral-sh/ruff.git
synced 2025-10-28 02:39:59 +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 |
||
|---|---|---|
| .. | ||
| corpus | ||
| mdtest | ||
| primer | ||
| README.md | ||
Markdown files within the mdtest/ subdirectory are tests of type inference and type checking;
executed by the tests/mdtest.rs integration test.
See crates/ty_test/README.md for documentation of this test format.