@@ -61,7 +61,7 @@ reveal_type(c) # revealed: Literal[4]
61
61
### Uneven unpacking (1)
62
62
63
63
``` py
64
- # TODO : Add diagnostic (there aren't enough values to unpack)
64
+ # error: [invalid-assignment] "Not enough values to unpack (expected 3, got 2)"
65
65
(a, b, c) = (1 , 2 )
66
66
reveal_type(a) # revealed: Literal[1]
67
67
reveal_type(b) # revealed: Literal[2]
@@ -71,7 +71,7 @@ reveal_type(c) # revealed: Unknown
71
71
### Uneven unpacking (2)
72
72
73
73
``` py
74
- # TODO : Add diagnostic (too many values to unpack)
74
+ # error: [invalid-assignment] "Too many values to unpack (expected 2, got 3)"
75
75
(a, b) = (1 , 2 , 3 )
76
76
reveal_type(a) # revealed: Literal[1]
77
77
reveal_type(b) # revealed: Literal[2]
@@ -80,7 +80,7 @@ reveal_type(b) # revealed: Literal[2]
80
80
### Starred expression (1)
81
81
82
82
``` py
83
- # TODO : Add diagnostic (need more values to unpack)
83
+ # error: [invalid-assignment] "Not enough values to unpack (expected 3 or more, got 2)"
84
84
[a, * b, c, d] = (1 , 2 )
85
85
reveal_type(a) # revealed: Literal[1]
86
86
# TODO : Should be list[Any] once support for assigning to starred expression is added
@@ -133,7 +133,7 @@ reveal_type(c) # revealed: @Todo(starred unpacking)
133
133
### Starred expression (6)
134
134
135
135
``` py
136
- # TODO : Add diagnostic (need more values to unpack)
136
+ # error: [invalid-assignment] "Not enough values to unpack (expected 5 or more, got 1)"
137
137
(a, b, c, * d, e, f) = (1 ,)
138
138
reveal_type(a) # revealed: Literal[1]
139
139
reveal_type(b) # revealed: Unknown
@@ -199,7 +199,7 @@ reveal_type(b) # revealed: LiteralString
199
199
### Uneven unpacking (1)
200
200
201
201
``` py
202
- # TODO : Add diagnostic (there aren't enough values to unpack)
202
+ # error: [invalid-assignment] "Not enough values to unpack (expected 3, got 2)"
203
203
a, b, c = " ab"
204
204
reveal_type(a) # revealed: LiteralString
205
205
reveal_type(b) # revealed: LiteralString
@@ -209,7 +209,7 @@ reveal_type(c) # revealed: Unknown
209
209
### Uneven unpacking (2)
210
210
211
211
``` py
212
- # TODO : Add diagnostic (too many values to unpack)
212
+ # error: [invalid-assignment] "Too many values to unpack (expected 2, got 3)"
213
213
a, b = " abc"
214
214
reveal_type(a) # revealed: LiteralString
215
215
reveal_type(b) # revealed: LiteralString
@@ -218,7 +218,7 @@ reveal_type(b) # revealed: LiteralString
218
218
### Starred expression (1)
219
219
220
220
``` py
221
- # TODO : Add diagnostic (need more values to unpack)
221
+ # error: [invalid-assignment] "Not enough values to unpack (expected 3 or more, got 2)"
222
222
(a, * b, c, d) = " ab"
223
223
reveal_type(a) # revealed: LiteralString
224
224
# TODO : Should be list[LiteralString] once support for assigning to starred expression is added
@@ -271,7 +271,7 @@ reveal_type(c) # revealed: @Todo(starred unpacking)
271
271
### Unicode
272
272
273
273
``` py
274
- # TODO : Add diagnostic (need more values to unpack)
274
+ # error: [invalid-assignment] "Not enough values to unpack (expected 2, got 1)"
275
275
(a, b) = " é"
276
276
277
277
reveal_type(a) # revealed: LiteralString
@@ -281,7 +281,7 @@ reveal_type(b) # revealed: Unknown
281
281
### Unicode escape (1)
282
282
283
283
``` py
284
- # TODO : Add diagnostic (need more values to unpack)
284
+ # error: [invalid-assignment] "Not enough values to unpack (expected 2, got 1)"
285
285
(a, b) = " \u9E6C "
286
286
287
287
reveal_type(a) # revealed: LiteralString
@@ -291,7 +291,7 @@ reveal_type(b) # revealed: Unknown
291
291
### Unicode escape (2)
292
292
293
293
``` py
294
- # TODO : Add diagnostic (need more values to unpack)
294
+ # error: [invalid-assignment] "Not enough values to unpack (expected 2, got 1)"
295
295
(a, b) = " \U0010FFFF "
296
296
297
297
reveal_type(a) # revealed: LiteralString
@@ -383,7 +383,8 @@ def _(arg: tuple[int, bytes, int] | tuple[int, int, str, int, bytes]):
383
383
384
384
``` py
385
385
def _ (arg : tuple[int , bytes , int ] | tuple[int , int , str , int , bytes ]):
386
- # TODO : Add diagnostic (too many values to unpack)
386
+ # error: [invalid-assignment] "Too many values to unpack (expected 2, got 3)"
387
+ # error: [invalid-assignment] "Too many values to unpack (expected 2, got 5)"
387
388
a, b = arg
388
389
reveal_type(a) # revealed: int
389
390
reveal_type(b) # revealed: bytes | int
@@ -393,7 +394,8 @@ def _(arg: tuple[int, bytes, int] | tuple[int, int, str, int, bytes]):
393
394
394
395
``` py
395
396
def _ (arg : tuple[int , bytes ] | tuple[int , str ]):
396
- # TODO : Add diagnostic (there aren't enough values to unpack)
397
+ # error: [invalid-assignment] "Not enough values to unpack (expected 3, got 2)"
398
+ # error: [invalid-assignment] "Not enough values to unpack (expected 3, got 2)"
397
399
a, b, c = arg
398
400
reveal_type(a) # revealed: int
399
401
reveal_type(b) # revealed: bytes | str
@@ -536,6 +538,7 @@ for a, b in ((1, 2), ("a", "b")):
536
538
# error: "Object of type `Literal[1]` is not iterable"
537
539
# error: "Object of type `Literal[2]` is not iterable"
538
540
# error: "Object of type `Literal[4]` is not iterable"
541
+ # error: [invalid-assignment] "Not enough values to unpack (expected 2, got 1)"
539
542
for a, b in (1 , 2 , (3 , " a" ), 4 , (5 , " b" ), " c" ):
540
543
reveal_type(a) # revealed: Unknown | Literal[3, 5] | LiteralString
541
544
reveal_type(b) # revealed: Unknown | Literal["a", "b"]
0 commit comments