ruff
fff823d2 - [ty] Skip inferred writes when a declaration determines an instance member (#29702)

Commit
2 days ago
[ty] Skip inferred writes when a declaration determines an instance member (#29702) ## Summary In a reduced example from [PyTorch](https://github.com/pytorch/pytorch/blob/ab92945cea42e47ae398aead69af0872d340ea0f/torch/_dynamo/variables/misc.py#L2755), ty now opens 8 Python files instead of 68 to resolve `tx.output.side_effects`. Across four profiling runs with a single worker, median CPU time fell from 1.20 s to 0.25 s for that example and from 1.99 s to 1.54 s for the full `misc.py` file. Diagnostics were unchanged. When looking up an instance attribute, ty inferred assignments in method bodies before checking whether an annotation already determined the type. Those assignments could pull in modules that the lookup never needed. We now return the declared type first. If a subclass default shadows an inherited declaration, augmented assignments such as `self.x += 1` in a base class can still affect the attribute’s type, so we continue to collect them. Co-authored-by: Charlie Marsh <charliemarsh@openai.com>
Author
Parents
Loading