ruff
2fc445f0 - [ty] Diagnose invalid __getattr__ calls (#27502)

Commit
83 days ago
[ty] Diagnose invalid __getattr__ calls (#27502) ## Summary Previously, an invalid `__getattr__` method caused us to report that the requested attribute was missing, even though Python actually invokes the method and raises `TypeError`: ```py class Example: def __getattr__(self) -> str: return "fallback" Example().missing # error: [invalid-attribute-access] ``` We now propagate failed implicit `__getattr__` calls through the generalized member-lookup error introduced in #27400, so the diagnostic identifies the invalid call and preserves the method's return type for error recovery. This applies to instance and metaclass attribute lookup, including incompatible attribute-name parameters. Literal-restricted `__getattr__` methods continue to treat unsupported names as missing attributes, and already-defined attributes still bypass the fallback. Closes https://github.com/astral-sh/ty/issues/135.
Author
Parents
Loading