Commit 0d4f7dd
authored
[ty] Treat
## Summary
Pull this out of #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.__new__ as a static method (#20212)1 parent cb1ba0d commit 0d4f7dd
File tree
3 files changed
+10
-10
lines changed- crates/ty_python_semantic/src/types
- call
3 files changed
+10
-10
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
290 | 290 | | |
291 | 291 | | |
292 | 292 | | |
293 | | - | |
294 | | - | |
| 293 | + | |
295 | 294 | | |
296 | 295 | | |
297 | 296 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
3 | 3 | | |
4 | 4 | | |
5 | 5 | | |
6 | | - | |
7 | | - | |
8 | | - | |
9 | | - | |
| 6 | + | |
| 7 | + | |
10 | 8 | | |
11 | 9 | | |
12 | 10 | | |
| |||
1257 | 1255 | | |
1258 | 1256 | | |
1259 | 1257 | | |
1260 | | - | |
1261 | | - | |
1262 | | - | |
1263 | | - | |
| 1258 | + | |
1264 | 1259 | | |
1265 | 1260 | | |
1266 | 1261 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
731 | 731 | | |
732 | 732 | | |
733 | 733 | | |
| 734 | + | |
| 735 | + | |
| 736 | + | |
| 737 | + | |
| 738 | + | |
| 739 | + | |
734 | 740 | | |
735 | 741 | | |
736 | 742 | | |
| |||
0 commit comments