ruff
4efb2646 - [ty] Contextually infer custom `__setattr__` assignments (#27015)

Commit
79 days ago
[ty] Contextually infer custom `__setattr__` assignments (#27015) ## Summary Prior to this change, we inferred the right-hand side of an unresolved instance-attribute assignment before checking a custom `__setattr__`. That discarded the setter's expected type, leaving lambda parameters as `Unknown` and rejecting otherwise-valid `TypedDict` literals: ```py class Payload(TypedDict): value: int class Custom: def __setattr__(self, name: str, value: Callable[[int], int] | Payload) -> None: ... instance = Custom() instance.callback = lambda value: value.missing # Previously: no diagnostic instance.payload = {"value": 1} # Previously: unresolved-attribute ``` We now contextually infer unresolved instance assignments against the custom setter, so the lambda parameter is correctly inferred as `int` and the `TypedDict` literal is accepted. Explicit attributes and terminal setters retain their existing behavior.
Author
Parents
Loading