ruff
b3c40052 - [ty] No boundness analysis for implicit instance attributes (#20128)

Commit
37 days ago
[ty] No boundness analysis for implicit instance attributes (#20128) ## Summary With this PR, we stop performing boundness analysis for implicit instance attributes: ```py class C: def __init__(self): if False: self.x = 1 C().x # would previously show an error, with this PR we pretend the attribute exists ``` This PR is potentially just a temporary measure until we find a better fix. But I have already invested a lot of time trying to find the root cause of https://github.com/astral-sh/ty/issues/758 (and [this example](https://github.com/astral-sh/ty/issues/758#issuecomment-3206108262), which I'm not entirely sure is related) and I still don't understand what is going on. This PR fixes the performance problems in both of these problems (in a rather crude way). The impact of the proposed change on the ecosystem is small, and the three new diagnostics are arguably true positives (previously hidden because we considered the code unreachable, based on e.g. `assert`ions that depended on implicit instance attributes). So this seems like a reasonable fix for now. Note that we still support cases like these: ```py class D: if False: # or any other expression that statically evaluates to `False` x: int = 1 D().x # still an error class E: if False: # or any other expression that statically evaluates to `False` def f(self): self.x = 1 E().x # still an error ``` closes https://github.com/astral-sh/ty/issues/758 ## Test Plan Updated tests, benchmark results
Author
Parents
Loading