Commit 54a2c6d
authored
Fix type inference of positional parameter in class pattern involving builtin subtype (python#18141)
Fixes python#18140
### Demo
```python
from typing import reveal_type
class A(str):
pass
class B(str):
__match_args__ = ("b",)
@Property
def b(self) -> int: return 1
match A("a"):
case A(a):
reveal_type(a) # before: Revealed type is "__main__.A"
# after: Revealed type is "__main__.A"
print(type(a)) # output: <class '__main__.A'>
match B("b"):
case B(b):
reveal_type(b) # before: Revealed type is "__main__.B"
# after: Revealed type is "builtins.int"
print(type(b)) # output: <class 'int'>
```1 parent 3b00002 commit 54a2c6d
2 files changed
+22
-1
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
693 | 693 | | |
694 | 694 | | |
695 | 695 | | |
696 | | - | |
| 696 | + | |
| 697 | + | |
| 698 | + | |
697 | 699 | | |
698 | 700 | | |
699 | 701 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
648 | 648 | | |
649 | 649 | | |
650 | 650 | | |
| 651 | + | |
| 652 | + | |
| 653 | + | |
| 654 | + | |
| 655 | + | |
| 656 | + | |
| 657 | + | |
| 658 | + | |
| 659 | + | |
| 660 | + | |
| 661 | + | |
| 662 | + | |
| 663 | + | |
| 664 | + | |
| 665 | + | |
| 666 | + | |
| 667 | + | |
| 668 | + | |
| 669 | + | |
651 | 670 | | |
652 | 671 | | |
653 | 672 | | |
| |||
0 commit comments