Commit 21cc1c7
authored
Improve handling of attribute access on class objects (#14988)
Fixes #14056
#14056 was originally reported as a mypyc issue (because that's how it
presented itself to the user), but the underlying bug is really a bug to
do with how mypy understands metaclasses. On mypy `master`:
```py
class Meta(type):
bar: str
class Foo(metaclass=Meta):
bar: int
reveal_type(Foo().bar) # Revealed type is int (correct!)
reveal_type(Foo.bar) # Revealed type is int, but should be str
```
This PR fixes that incorrect behaviour.
Since this is really a mypy bug rather than a mypyc bug, I haven't added
a mypyc test, but I'm happy to if that would be useful. (I'll need some
guidance as to exactly where it should go -- I don't know much about
mypyc internals!)1 parent db5b5af commit 21cc1c7
File tree
4 files changed
+76
-5
lines changed- mypy
- test-data/unit
4 files changed
+76
-5
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
388 | 388 | | |
389 | 389 | | |
390 | 390 | | |
391 | | - | |
| 391 | + | |
392 | 392 | | |
393 | 393 | | |
394 | 394 | | |
| |||
434 | 434 | | |
435 | 435 | | |
436 | 436 | | |
| 437 | + | |
| 438 | + | |
| 439 | + | |
| 440 | + | |
437 | 441 | | |
438 | 442 | | |
439 | | - | |
| 443 | + | |
| 444 | + | |
| 445 | + | |
440 | 446 | | |
441 | 447 | | |
442 | 448 | | |
443 | 449 | | |
444 | 450 | | |
445 | 451 | | |
446 | | - | |
447 | | - | |
448 | 452 | | |
449 | 453 | | |
450 | 454 | | |
| |||
893 | 897 | | |
894 | 898 | | |
895 | 899 | | |
| 900 | + | |
| 901 | + | |
896 | 902 | | |
897 | 903 | | |
898 | 904 | | |
| |||
919 | 925 | | |
920 | 926 | | |
921 | 927 | | |
| 928 | + | |
| 929 | + | |
| 930 | + | |
| 931 | + | |
| 932 | + | |
| 933 | + | |
| 934 | + | |
| 935 | + | |
| 936 | + | |
| 937 | + | |
| 938 | + | |
| 939 | + | |
| 940 | + | |
| 941 | + | |
| 942 | + | |
| 943 | + | |
922 | 944 | | |
923 | 945 | | |
924 | 946 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
325 | 325 | | |
326 | 326 | | |
327 | 327 | | |
328 | | - | |
| 328 | + | |
| 329 | + | |
| 330 | + | |
| 331 | + | |
329 | 332 | | |
330 | 333 | | |
331 | 334 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
4540 | 4540 | | |
4541 | 4541 | | |
4542 | 4542 | | |
| 4543 | + | |
| 4544 | + | |
| 4545 | + | |
| 4546 | + | |
| 4547 | + | |
| 4548 | + | |
| 4549 | + | |
| 4550 | + | |
| 4551 | + | |
| 4552 | + | |
| 4553 | + | |
| 4554 | + | |
| 4555 | + | |
| 4556 | + | |
| 4557 | + | |
| 4558 | + | |
| 4559 | + | |
| 4560 | + | |
| 4561 | + | |
| 4562 | + | |
| 4563 | + | |
| 4564 | + | |
| 4565 | + | |
| 4566 | + | |
| 4567 | + | |
| 4568 | + | |
| 4569 | + | |
| 4570 | + | |
| 4571 | + | |
| 4572 | + | |
| 4573 | + | |
| 4574 | + | |
| 4575 | + | |
4543 | 4576 | | |
4544 | 4577 | | |
4545 | 4578 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1987 | 1987 | | |
1988 | 1988 | | |
1989 | 1989 | | |
| 1990 | + | |
| 1991 | + | |
| 1992 | + | |
| 1993 | + | |
| 1994 | + | |
| 1995 | + | |
| 1996 | + | |
| 1997 | + | |
| 1998 | + | |
| 1999 | + | |
| 2000 | + | |
| 2001 | + | |
| 2002 | + | |
1990 | 2003 | | |
1991 | 2004 | | |
1992 | 2005 | | |
| |||
0 commit comments