@@ -234,7 +234,7 @@ txt(sys.stdout)
234234bin(sys.stdout)
235235[out]
236236_program.py:5: error: Argument 1 to "write" of "IO" has incompatible type "bytes"; expected "str"
237- _program.py:10: error: Argument 1 to "bin" has incompatible type "Union[ TextIO, Any] "; expected "IO[bytes]"
237+ _program.py:10: error: Argument 1 to "bin" has incompatible type "TextIO | Any"; expected "IO[bytes]"
238238
239239[case testBuiltinOpen]
240240f = open('x')
@@ -627,7 +627,7 @@ a + 1
627627_testMapStr.py:4: error: No overload variant of "__add__" of "list" matches argument type "int"
628628_testMapStr.py:4: note: Possible overload variants:
629629_testMapStr.py:4: note: def __add__(self, list[str], /) -> list[str]
630- _testMapStr.py:4: note: def [_S] __add__(self, list[_S], /) -> list[Union[_S, str] ]
630+ _testMapStr.py:4: note: def [_S] __add__(self, list[_S], /) -> list[_S | str]
631631
632632[case testRelativeImport]
633633import typing
@@ -762,7 +762,7 @@ def p(t: Tuple[str, ...]) -> None:
762762''.startswith(('x', b'y'))
763763[out]
764764_program.py:6: error: "str" not callable
765- _program.py:8: error: Argument 1 to "startswith" of "str" has incompatible type "tuple[str, bytes]"; expected "Union[ str, tuple[str, ...] ]"
765+ _program.py:8: error: Argument 1 to "startswith" of "str" has incompatible type "tuple[str, bytes]"; expected "str | tuple[str, ...]"
766766
767767[case testMultiplyTupleByInteger]
768768n = 4
@@ -772,7 +772,7 @@ t + 1
772772_program.py:3: error: No overload variant of "__add__" of "tuple" matches argument type "int"
773773_program.py:3: note: Possible overload variants:
774774_program.py:3: note: def __add__(self, tuple[str, ...], /) -> tuple[str, ...]
775- _program.py:3: note: def [_T] __add__(self, tuple[_T, ...], /) -> tuple[Union[ str, _T] , ...]
775+ _program.py:3: note: def [_T] __add__(self, tuple[_T, ...], /) -> tuple[str | _T , ...]
776776
777777[case testMultiplyTupleByIntegerReverse]
778778n = 4
@@ -782,7 +782,7 @@ t + 1
782782_program.py:3: error: No overload variant of "__add__" of "tuple" matches argument type "int"
783783_program.py:3: note: Possible overload variants:
784784_program.py:3: note: def __add__(self, tuple[str, ...], /) -> tuple[str, ...]
785- _program.py:3: note: def [_T] __add__(self, tuple[_T, ...], /) -> tuple[Union[ str, _T] , ...]
785+ _program.py:3: note: def [_T] __add__(self, tuple[_T, ...], /) -> tuple[str | _T , ...]
786786
787787[case testDictWithKeywordArgs]
788788from typing import Dict, Any, List
@@ -822,7 +822,7 @@ class MyDDict(t.DefaultDict[int,T], t.Generic[T]):
822822MyDDict(dict)['0']
823823MyDDict(dict)[0]
824824[out]
825- _program.py:6: error: Argument 1 to "defaultdict" has incompatible type "type[list[_T]]"; expected "Optional[ Callable[[], str]] "
825+ _program.py:6: error: Argument 1 to "defaultdict" has incompatible type "type[list[_T]]"; expected "Callable[[], str] | None "
826826_program.py:9: error: Invalid index type "str" for "defaultdict[int, str]"; expected type "int"
827827_program.py:9: error: Incompatible types in assignment (expression has type "int", target has type "str")
828828_program.py:19: error: Argument 1 to "tst" has incompatible type "defaultdict[str, list[Never]]"; expected "defaultdict[int, list[Never]]"
@@ -962,9 +962,9 @@ re.subn(bpat, lambda m: b'', b'')[0] + b''
962962[out]
963963_testReModuleBytes.py:9: error: No overload variant of "search" matches argument types "bytes", "str"
964964_testReModuleBytes.py:9: note: Possible overload variants:
965- _testReModuleBytes.py:9: note: def search(pattern: Union[ str, Pattern[str]] , string: str, flags: Union[ int, RegexFlag] = ...) -> Optional[ Match[str]]
966- _testReModuleBytes.py:9: note: def search(pattern: Union[ bytes, Pattern[bytes]] , string: Buffer, flags: Union[ int, RegexFlag] = ...) -> Optional[ Match[bytes]]
967- _testReModuleBytes.py:13: error: Argument 1 to "search" has incompatible type "Pattern[bytes]"; expected "Union[ str, Pattern[str] ]"
965+ _testReModuleBytes.py:9: note: def search(pattern: str | Pattern[str], string: str, flags: int | RegexFlag = ...) -> Match[str] | None
966+ _testReModuleBytes.py:9: note: def search(pattern: bytes | Pattern[bytes], string: Buffer, flags: int | RegexFlag = ...) -> Match[bytes] | None
967+ _testReModuleBytes.py:13: error: Argument 1 to "search" has incompatible type "Pattern[bytes]"; expected "str | Pattern[str]"
968968
969969[case testReModuleString]
970970# Regression tests for various overloads in the re module -- string version
@@ -993,9 +993,9 @@ re.subn(spat, lambda m: '', '')[0] + ''
993993[out]
994994_testReModuleString.py:9: error: No overload variant of "search" matches argument types "str", "bytes"
995995_testReModuleString.py:9: note: Possible overload variants:
996- _testReModuleString.py:9: note: def search(pattern: Union[ str, Pattern[str]] , string: str, flags: Union[ int, RegexFlag] = ...) -> Optional[ Match[str]]
997- _testReModuleString.py:9: note: def search(pattern: Union[ bytes, Pattern[bytes]] , string: Buffer, flags: Union[ int, RegexFlag] = ...) -> Optional[ Match[bytes]]
998- _testReModuleString.py:13: error: Argument 1 to "search" has incompatible type "Pattern[str]"; expected "Union[ bytes, Pattern[bytes] ]"
996+ _testReModuleString.py:9: note: def search(pattern: str | Pattern[str], string: str, flags: int | RegexFlag = ...) -> Match[str] | None
997+ _testReModuleString.py:9: note: def search(pattern: bytes | Pattern[bytes], string: Buffer, flags: int | RegexFlag = ...) -> Match[bytes] | None
998+ _testReModuleString.py:13: error: Argument 1 to "search" has incompatible type "Pattern[str]"; expected "bytes | Pattern[bytes]"
999999
10001000[case testListSetitemTuple]
10011001from typing import List, Tuple
@@ -1062,8 +1062,8 @@ _testTypedDictGet.py:11: note: def get(self, str, /) -> object
10621062_testTypedDictGet.py:11: note: def get(self, str, /, default: object) -> object
10631063_testTypedDictGet.py:11: note: def [_T] get(self, str, /, default: _T) -> object
10641064_testTypedDictGet.py:13: note: Revealed type is "builtins.object"
1065- _testTypedDictGet.py:16: note: Revealed type is "Union[ builtins.int, None] "
1066- _testTypedDictGet.py:17: note: Revealed type is "Union[ builtins.str, None] "
1065+ _testTypedDictGet.py:16: note: Revealed type is "builtins.int | None"
1066+ _testTypedDictGet.py:17: note: Revealed type is "builtins.str | None"
10671067_testTypedDictGet.py:18: note: Revealed type is "builtins.object"
10681068_testTypedDictGet.py:19: error: All overload variants of "get" of "Mapping" require at least one argument
10691069_testTypedDictGet.py:19: note: Possible overload variants:
@@ -1184,10 +1184,10 @@ for a, b in x.items():
11841184[out]
11851185_testNoCrashOnGenericUnionUnpacking.py:6: note: Revealed type is "builtins.str"
11861186_testNoCrashOnGenericUnionUnpacking.py:7: note: Revealed type is "builtins.str"
1187- _testNoCrashOnGenericUnionUnpacking.py:10: note: Revealed type is "Union[ builtins.str, builtins.int] "
1188- _testNoCrashOnGenericUnionUnpacking.py:11: note: Revealed type is "Union[ builtins.str, builtins.int] "
1189- _testNoCrashOnGenericUnionUnpacking.py:15: note: Revealed type is "Union[ builtins.int, builtins.str] "
1190- _testNoCrashOnGenericUnionUnpacking.py:16: note: Revealed type is "Union[ builtins.int, builtins.str] "
1187+ _testNoCrashOnGenericUnionUnpacking.py:10: note: Revealed type is "builtins.str | builtins.int"
1188+ _testNoCrashOnGenericUnionUnpacking.py:11: note: Revealed type is "builtins.str | builtins.int"
1189+ _testNoCrashOnGenericUnionUnpacking.py:15: note: Revealed type is "builtins.int | builtins.str"
1190+ _testNoCrashOnGenericUnionUnpacking.py:16: note: Revealed type is "builtins.int | builtins.str"
11911191
11921192[case testMetaclassOpAccess]
11931193from typing import Type
@@ -1234,7 +1234,7 @@ bar: Type[Union[A, B]]
12341234res = bar * 4
12351235reveal_type(res)
12361236[out]
1237- _testMetaclassOpAccessUnion.py:16: note: Revealed type is "Union[ builtins.str, builtins.int] "
1237+ _testMetaclassOpAccessUnion.py:16: note: Revealed type is "builtins.str | builtins.int"
12381238
12391239[case testMetaclassOpAccessAny]
12401240from typing import Type
@@ -1303,9 +1303,9 @@ class B:
13031303class C:
13041304 __slots__: List[int] = []
13051305[out]
1306- _testInvalidSlots.py:3: error: Invalid type for "__slots__" (actual type "int", expected type "Union[ str, Iterable[str] ]")
1307- _testInvalidSlots.py:5: error: Invalid type for "__slots__" (actual type "tuple[int, int]", expected type "Union[ str, Iterable[str] ]")
1308- _testInvalidSlots.py:7: error: Invalid type for "__slots__" (actual type "list[int]", expected type "Union[ str, Iterable[str] ]")
1306+ _testInvalidSlots.py:3: error: Invalid type for "__slots__" (actual type "int", expected type "str | Iterable[str]")
1307+ _testInvalidSlots.py:5: error: Invalid type for "__slots__" (actual type "tuple[int, int]", expected type "str | Iterable[str]")
1308+ _testInvalidSlots.py:7: error: Invalid type for "__slots__" (actual type "list[int]", expected type "str | Iterable[str]")
13091309
13101310[case testDictWithStarStarSpecialCase]
13111311from typing import Dict
@@ -1609,9 +1609,9 @@ else:
16091609
16101610[out]
16111611_testNarrowTypeForDictKeys.py:6: note: Revealed type is "builtins.str"
1612- _testNarrowTypeForDictKeys.py:8: note: Revealed type is "Union[ builtins.str, None] "
1612+ _testNarrowTypeForDictKeys.py:8: note: Revealed type is "builtins.str | None"
16131613_testNarrowTypeForDictKeys.py:13: note: Revealed type is "builtins.str"
1614- _testNarrowTypeForDictKeys.py:15: note: Revealed type is "Union[ builtins.str, None] "
1614+ _testNarrowTypeForDictKeys.py:15: note: Revealed type is "builtins.str | None"
16151615
16161616[case testTypeAliasWithNewStyleUnion]
16171617# flags: --python-version 3.10
@@ -1651,8 +1651,8 @@ def foo(x: T) -> T:
16511651 return x
16521652[out]
16531653_testTypeAliasWithNewStyleUnion.py:5: note: Revealed type is "typing._SpecialForm"
1654- _testTypeAliasWithNewStyleUnion.py:25: note: Revealed type is "Union[ type[builtins.int], builtins.str] "
1655- _testTypeAliasWithNewStyleUnion.py:28: note: Revealed type is "Union[ type[builtins.int], builtins.str] "
1654+ _testTypeAliasWithNewStyleUnion.py:25: note: Revealed type is "type[builtins.int] | builtins.str"
1655+ _testTypeAliasWithNewStyleUnion.py:28: note: Revealed type is "type[builtins.int] | builtins.str"
16561656
16571657[case testTypeAliasWithNewStyleUnionInStub]
16581658import m
@@ -1705,12 +1705,12 @@ CU4: TypeAlias = int | Callable[[str | bool], str]
17051705[out]
17061706m.pyi:5: note: Revealed type is "typing._SpecialForm"
17071707m.pyi:22: note: Revealed type is "types.UnionType[type[builtins.int], builtins.str]"
1708- _testTypeAliasWithNewStyleUnionInStub.py:3: note: Revealed type is "Union[ type[builtins.int], builtins.str] "
1709- _testTypeAliasWithNewStyleUnionInStub.py:5: note: Revealed type is "Union[ type[builtins.int], builtins.str] "
1710- _testTypeAliasWithNewStyleUnionInStub.py:7: note: Revealed type is "Union[ type[builtins.int], builtins.str] "
1711- _testTypeAliasWithNewStyleUnionInStub.py:9: note: Revealed type is "Union[ type[builtins.int], builtins.str] "
1712- _testTypeAliasWithNewStyleUnionInStub.py:11: note: Revealed type is "Union[ builtins.str, type[builtins.int] ]"
1713- _testTypeAliasWithNewStyleUnionInStub.py:13: note: Revealed type is "Union[ builtins.str, type[builtins.int] ]"
1708+ _testTypeAliasWithNewStyleUnionInStub.py:3: note: Revealed type is "type[builtins.int] | builtins.str"
1709+ _testTypeAliasWithNewStyleUnionInStub.py:5: note: Revealed type is "type[builtins.int] | builtins.str"
1710+ _testTypeAliasWithNewStyleUnionInStub.py:7: note: Revealed type is "type[builtins.int] | builtins.str"
1711+ _testTypeAliasWithNewStyleUnionInStub.py:9: note: Revealed type is "type[builtins.int] | builtins.str"
1712+ _testTypeAliasWithNewStyleUnionInStub.py:11: note: Revealed type is "builtins.str | type[builtins.int]"
1713+ _testTypeAliasWithNewStyleUnionInStub.py:13: note: Revealed type is "builtins.str | type[builtins.int]"
17141714
17151715[case testEnumNameWorkCorrectlyOn311]
17161716# flags: --python-version 3.11
@@ -1730,7 +1730,7 @@ reveal_type(e.foo)
17301730reveal_type(E.Y.foo)
17311731[out]
17321732_testEnumNameWorkCorrectlyOn311.py:11: note: Revealed type is "builtins.str"
1733- _testEnumNameWorkCorrectlyOn311.py:12: note: Revealed type is "Union[ Literal[1]?, Literal[2]?] "
1733+ _testEnumNameWorkCorrectlyOn311.py:12: note: Revealed type is "Literal[1]? | Literal[2]?"
17341734_testEnumNameWorkCorrectlyOn311.py:13: note: Revealed type is "Literal['X']?"
17351735_testEnumNameWorkCorrectlyOn311.py:14: note: Revealed type is "builtins.int"
17361736_testEnumNameWorkCorrectlyOn311.py:15: note: Revealed type is "builtins.int"
@@ -1799,9 +1799,9 @@ WrongEllipsis = tuple[float, float, ...] | str # Error
17991799
18001800reveal_type(tuple[int, str]((1, "x")))
18011801[out]
1802- _testTupleWithDifferentArgsPy310.py:15: note: Revealed type is "Union[ builtins.str, tuple[builtins.float, builtins.float, builtins.str] ]"
1803- _testTupleWithDifferentArgsPy310.py:16: note: Revealed type is "Union[ tuple[builtins.float], builtins.str] "
1804- _testTupleWithDifferentArgsPy310.py:17: note: Revealed type is "Union[ builtins.tuple[builtins.float, ...], builtins.str] "
1802+ _testTupleWithDifferentArgsPy310.py:15: note: Revealed type is "builtins.str | tuple[builtins.float, builtins.float, builtins.str]"
1803+ _testTupleWithDifferentArgsPy310.py:16: note: Revealed type is "tuple[builtins.float] | builtins.str"
1804+ _testTupleWithDifferentArgsPy310.py:17: note: Revealed type is "builtins.tuple[builtins.float, ...] | builtins.str"
18051805_testTupleWithDifferentArgsPy310.py:18: note: Revealed type is "tuple[builtins.float, builtins.str]"
18061806_testTupleWithDifferentArgsPy310.py:19: note: Revealed type is "builtins.tuple[builtins.float, ...]"
18071807_testTupleWithDifferentArgsPy310.py:20: note: Revealed type is "builtins.list[tuple[builtins.int, builtins.str]]"
@@ -2059,7 +2059,7 @@ class Description:
20592059def f(d: Description) -> None:
20602060 reveal_type(d.name_fn)
20612061[out]
2062- _testDataclassStrictOptionalAlwaysSet.py:9: note: Revealed type is "def (Union[ builtins.int, None] ) -> Union[ builtins.str, None] "
2062+ _testDataclassStrictOptionalAlwaysSet.py:9: note: Revealed type is "def (builtins.int | None) -> builtins.str | None"
20632063
20642064[case testPEP695VarianceInference]
20652065# flags: --python-version=3.12
0 commit comments