|
1 | | -[case testUnionErrorSyntax] |
2 | | -# flags: --python-version 3.10 --no-force-union-syntax |
3 | | -from typing import Union |
4 | | -x : Union[bool, str] |
5 | | -x = 3 # E: Incompatible types in assignment (expression has type "int", variable has type "bool | str") |
6 | | - |
7 | 1 | [case testOrErrorSyntax] |
8 | | -# flags: --python-version 3.10 --force-union-syntax |
| 2 | +# flags: --python-version 3.10 |
9 | 3 | from typing import Union |
10 | 4 | x : Union[bool, str] |
11 | | -x = 3 # E: Incompatible types in assignment (expression has type "int", variable has type "Union[bool, str]") |
| 5 | +x = 3 # E: Incompatible types in assignment (expression has type "int", variable has type "bool | str") |
12 | 6 |
|
13 | 7 | [case testOrNoneErrorSyntax] |
14 | | -# flags: --python-version 3.10 --no-force-union-syntax |
| 8 | +# flags: --python-version 3.10 |
15 | 9 | from typing import Union |
16 | 10 | x : Union[bool, None] |
17 | 11 | x = 3 # E: Incompatible types in assignment (expression has type "int", variable has type "bool | None") |
18 | 12 |
|
19 | | -[case testOptionalErrorSyntax] |
20 | | -# flags: --python-version 3.10 --force-union-syntax |
21 | | -from typing import Union |
22 | | -x : Union[bool, None] |
23 | | -x = 3 # E: Incompatible types in assignment (expression has type "int", variable has type "Optional[bool]") |
24 | | - |
25 | 13 | [case testNoneAsFinalItem] |
26 | | -# flags: --python-version 3.10 --no-force-union-syntax |
| 14 | +# flags: --python-version 3.10 |
27 | 15 | from typing import Union |
28 | 16 | x : Union[bool, None, str] |
29 | 17 | x = 3 # E: Incompatible types in assignment (expression has type "int", variable has type "bool | str | None") |
30 | 18 |
|
31 | 19 | [case testLiteralOrErrorSyntax] |
32 | | -# flags: --python-version 3.10 --no-force-union-syntax |
| 20 | +# flags: --python-version 3.10 |
33 | 21 | from typing import Literal, Union |
34 | 22 | x : Union[Literal[1], Literal[2], str] |
35 | 23 | x = 3 # E: Incompatible types in assignment (expression has type "Literal[3]", variable has type "Literal[1, 2] | str") |
36 | 24 | [builtins fixtures/tuple.pyi] |
37 | 25 |
|
38 | | -[case testLiteralUnionErrorSyntax] |
39 | | -# flags: --python-version 3.10 --force-union-syntax |
40 | | -from typing import Literal, Union |
41 | | -x : Union[Literal[1], Literal[2], str] |
42 | | -x = 3 # E: Incompatible types in assignment (expression has type "Literal[3]", variable has type "Union[str, Literal[1, 2]]") |
43 | | -[builtins fixtures/tuple.pyi] |
44 | | - |
45 | 26 | [case testLiteralOrNoneErrorSyntax] |
46 | | -# flags: --python-version 3.10 --no-force-union-syntax |
| 27 | +# flags: --python-version 3.10 |
47 | 28 | from typing import Literal, Union |
48 | 29 | x : Union[Literal[1], None] |
49 | 30 | x = 3 # E: Incompatible types in assignment (expression has type "Literal[3]", variable has type "Literal[1] | None") |
50 | 31 | [builtins fixtures/tuple.pyi] |
51 | 32 |
|
52 | | -[case testLiteralOptionalErrorSyntax] |
53 | | -# flags: --python-version 3.10 --force-union-syntax |
54 | | -from typing import Literal, Union |
55 | | -x : Union[Literal[1], None] |
56 | | -x = 3 # E: Incompatible types in assignment (expression has type "Literal[3]", variable has type "Optional[Literal[1]]") |
57 | | -[builtins fixtures/tuple.pyi] |
58 | | - |
59 | | -[case testUnionSyntaxRecombined] |
60 | | -# flags: --python-version 3.10 --force-union-syntax --allow-redefinition-new --local-partial-types |
61 | | -# The following revealed type is recombined because the finally body is visited twice. |
62 | | -try: |
63 | | - x = 1 |
64 | | - x = "" |
65 | | - x = {1: ""} |
66 | | -finally: |
67 | | - reveal_type(x) # N: Revealed type is "Union[builtins.int, builtins.str, builtins.dict[builtins.int, builtins.str]]" |
68 | | -[builtins fixtures/isinstancelist.pyi] |
69 | | - |
70 | 33 | [case testOrSyntaxRecombined] |
71 | | -# flags: --python-version 3.10 --no-force-union-syntax --allow-redefinition-new --local-partial-types |
| 34 | +# flags: --python-version 3.10 --allow-redefinition-new --local-partial-types |
72 | 35 | # The following revealed type is recombined because the finally body is visited twice. |
73 | 36 | try: |
74 | 37 | x = 1 |
|
0 commit comments