ruff
0d4f7dde - [ty] Treat `__new__` as a static method (#20212)

Commit
14 days ago
[ty] Treat `__new__` as a static method (#20212) ## Summary Pull this out of https://github.com/astral-sh/ruff/pull/18473 as an isolated change to make sure it has no adverse effects. The wrong behavior is observable on `main` for something like ```py class C: def __new__(cls) -> "C": cls.x = 1 C.x # previously: Attribute `x` can only be accessed on instances # now: Type `<class 'C'>` has no attribute `x` ``` where we currently treat `x` as an *instance* attribute (because we consider `__new__` to be a normal function and `cls` to be the "self" attribute). With this PR, we do not consider `x` to be an attribute, neither on the class nor on instances of `C`. If this turns out to be an important feature, we should add it intentionally, instead of accidentally. ## Test Plan Ecosystem checks.
Author
Parents
Loading