mirror of
https://github.com/microsoft/pyright.git
synced 2024-10-05 20:38:25 +03:00
Fixed bug in narrowing logic for sequence pattern magic where special cases of str
, bytes
, and bytearray
were not handled correctly. This addresses #6670. (#6671)
This commit is contained in:
parent
0e71f1dbf9
commit
07568b047d
@ -1236,6 +1236,13 @@ function getSequencePatternInfo(
|
|||||||
ClassType.isBuiltIn(mroClass, 'bytes') ||
|
ClassType.isBuiltIn(mroClass, 'bytes') ||
|
||||||
ClassType.isBuiltIn(mroClass, 'bytearray')
|
ClassType.isBuiltIn(mroClass, 'bytearray')
|
||||||
) {
|
) {
|
||||||
|
// This is definitely not a match.
|
||||||
|
sequenceInfo.push({
|
||||||
|
subtype,
|
||||||
|
entryTypes: [],
|
||||||
|
isIndeterminateLength: true,
|
||||||
|
isDefiniteNoMatch: true,
|
||||||
|
});
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -427,3 +427,11 @@ def test_negative_narrowing6(a: str | None, b: str | None):
|
|||||||
reveal_type(x, expected_text="tuple[None, str | None]")
|
reveal_type(x, expected_text="tuple[None, str | None]")
|
||||||
case (a, b) as x:
|
case (a, b) as x:
|
||||||
reveal_type(x, expected_text="tuple[str | None, str | None]")
|
reveal_type(x, expected_text="tuple[str | None, str | None]")
|
||||||
|
|
||||||
|
|
||||||
|
def test_negative_narrowing7(a: tuple[str, str] | str):
|
||||||
|
match a:
|
||||||
|
case (_, _):
|
||||||
|
reveal_type(a, expected_text="tuple[str, str]")
|
||||||
|
case _:
|
||||||
|
reveal_type(a, expected_text="str")
|
||||||
|
Loading…
Reference in New Issue
Block a user