Repository navigation
Commit cc10d51
committed
Prefer the reflected operator method only when the operand types differ
check_op_reversible gave the reflected method priority whenever covers_at_runtime(right, left) held, but that also holds for equal operand types -- and the data model gives the reflected method priority only if the operands are of different types. For a < b with a and b of the same class where __lt__ and __gt__ are defined in different classes of the MRO, mypy inferred the result type of the reflected method that CPython never calls first. Fixes #22386.1 parent 55472c0 commit cc10d51
2 files changed
Lines changed: 29 additions & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
4326 | 4326 | | |
4327 | 4327 | | |
4328 | 4328 | | |
4329 | | - | |
| 4329 | + | |
| 4330 | + | |
| 4331 | + | |
| 4332 | + | |
| 4333 | + | |
| 4334 | + | |
| 4335 | + | |
| 4336 | + | |
| 4337 | + | |
4330 | 4338 | | |
| 4339 | + | |
4331 | 4340 | | |
4332 | 4341 | | |
4333 | 4342 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
704 | 704 | | |
705 | 705 | | |
706 | 706 | | |
| 707 | + | |
| 708 | + | |
| 709 | + | |
| 710 | + | |
| 711 | + | |
| 712 | + | |
| 713 | + | |
| 714 | + | |
| 715 | + | |
| 716 | + | |
| 717 | + | |
| 718 | + | |
| 719 | + | |
| 720 | + | |
| 721 | + | |
| 722 | + | |
| 723 | + | |
| 724 | + | |
| 725 | + | |
707 | 726 | | |
708 | 727 | | |
709 | 728 | | |
| |||
0 commit comments