@@ -1241,3 +1241,46 @@ b = ("bar", 7)
1241
1241
reveal_type(a + b) # N: Revealed type is 'Tuple[builtins.int, builtins.str, builtins.int, builtins.str, builtins.int]'
1242
1242
1243
1243
[builtins fixtures/tuple.pyi]
1244
+
1245
+ [case testAssigningWithLongTupleInitializer]
1246
+ from typing import Tuple
1247
+
1248
+ # long initializer assignment with few mismatches
1249
+ t: Tuple[int, ...] = (1, 2, 3, 4, 5, 6, 7, 8, "str", "str", "str", 11) \
1250
+ # E: Incompatible types in assignment (3 tuple items are incompatible) \
1251
+ # N: Expression tuple item 8 has type "str"; "int" expected; \
1252
+ # N: Expression tuple item 9 has type "str"; "int" expected; \
1253
+ # N: Expression tuple item 10 has type "str"; "int" expected;
1254
+
1255
+ # long initializer assignment with more mismatches
1256
+ t1: Tuple[int, ...] = (1, 2, 3, 4, 5, 6, 7, 8, "str", "str", "str", "str") \
1257
+ # E: Incompatible types in assignment (4 tuple items are incompatible; 1 items are omitted) \
1258
+ # N: Expression tuple item 8 has type "str"; "int" expected; \
1259
+ # N: Expression tuple item 9 has type "str"; "int" expected; \
1260
+ # N: Expression tuple item 10 has type "str"; "int" expected;
1261
+
1262
+ # short tuple initializer assignment
1263
+ t2: Tuple[int, ...] = (1, 2, "s", 4) \
1264
+ # E: Incompatible types in assignment (expression has type "Tuple[int, int, str, int]", variable has type "Tuple[int, ...]")
1265
+
1266
+ # long initializer assignment with few mismatches, no ellipsis
1267
+ t3: Tuple[int, int, int, int, int, int, int, int, int, int, int, int] = (1, 2, 3, 4, 5, 6, 7, 8, 9, 10, "str", "str") \
1268
+ # E: Incompatible types in assignment (2 tuple items are incompatible) \
1269
+ # N: Expression tuple item 10 has type "str"; "int" expected; \
1270
+ # N: Expression tuple item 11 has type "str"; "int" expected;
1271
+
1272
+ # long initializer assignment with more mismatches, no ellipsis
1273
+ t4: Tuple[int, int, int, int, int, int, int, int, int, int, int, int] = (1, 2, 3, 4, 5, 6, 7, 8, "str", "str", "str", "str") \
1274
+ # E: Incompatible types in assignment (4 tuple items are incompatible; 1 items are omitted) \
1275
+ # N: Expression tuple item 8 has type "str"; "int" expected; \
1276
+ # N: Expression tuple item 9 has type "str"; "int" expected; \
1277
+ # N: Expression tuple item 10 has type "str"; "int" expected;
1278
+
1279
+ # short tuple initializer assignment, no ellipsis
1280
+ t5: Tuple[int, int] = (1, 2, "s", 4) # E: Incompatible types in assignment (expression has type "Tuple[int, int, str, int]", variable has type "Tuple[int, int]")
1281
+
1282
+ # long initializer assignment with mismatched pairs
1283
+ t6: Tuple[int, int, int, int, int, int, int, int, int, int, int, int] = (1, 2, 3, 4, 5, 6, 7, 8, "str", "str", "str", "str", 1, 1, 1, 1, 1) \
1284
+ # E: Incompatible types in assignment (expression has type Tuple[int, int, ... <15 more items>], variable has type Tuple[int, int, ... <10 more items>])
1285
+
1286
+ [builtins fixtures/tuple.pyi]
0 commit comments