Skip to content

Commit 4a56aaa

Browse files
rename 'variable unpack' -> 'variadic unpack'
1 parent 19649c5 commit 4a56aaa

File tree

3 files changed

+16
-16
lines changed

3 files changed

+16
-16
lines changed

mypy/typeanal.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1978,7 +1978,7 @@ def check_unpacks_in_list(self, items: list[Type]) -> list[Type]:
19781978

19791979
if num_unpacks > 1:
19801980
assert final_unpack is not None
1981-
self.fail("More than one variable Unpack in a type is not allowed", final_unpack.type)
1981+
self.fail("More than one variadic Unpack in a type is not allowed", final_unpack.type)
19821982
return new_items
19831983

19841984
def tuple_type(self, items: list[Type], line: int, column: int) -> TupleType:

test-data/unit/check-python312.test

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2038,13 +2038,13 @@ class Z: ... # E: Name "Z" already defined on line 2
20382038
# https://github.com/python/mypy/issues/18856
20392039
class A[*Ts]: ...
20402040

2041-
A[*tuple[int, ...], *tuple[int, ...]] # E: More than one variable Unpack in a type is not allowed
2042-
A[*tuple[*tuple[int, ...]], *tuple[*tuple[int, ...]]] # E: More than one variable Unpack in a type is not allowed
2043-
a: A[*tuple[int, ...], *tuple[int, ...]] # E: More than one variable Unpack in a type is not allowed
2044-
def foo(a: A[*tuple[int, ...], *tuple[int, ...]]): ... # E: More than one variable Unpack in a type is not allowed
2041+
A[*tuple[int, ...], *tuple[int, ...]] # E: More than one variadic Unpack in a type is not allowed
2042+
A[*tuple[*tuple[int, ...]], *tuple[*tuple[int, ...]]] # E: More than one variadic Unpack in a type is not allowed
2043+
a: A[*tuple[int, ...], *tuple[int, ...]] # E: More than one variadic Unpack in a type is not allowed
2044+
def foo(a: A[*tuple[int, ...], *tuple[int, ...]]): ... # E: More than one variadic Unpack in a type is not allowed
20452045

2046-
tuple[*tuple[int, ...], *tuple[int, ...]] # E: More than one variable Unpack in a type is not allowed
2047-
b: tuple[*tuple[int, ...], *tuple[int, ...]] # E: More than one variable Unpack in a type is not allowed
2046+
tuple[*tuple[int, ...], *tuple[int, ...]] # E: More than one variadic Unpack in a type is not allowed
2047+
b: tuple[*tuple[int, ...], *tuple[int, ...]] # E: More than one variadic Unpack in a type is not allowed
20482048
[builtins fixtures/tuple.pyi]
20492049
[typing fixtures/typing-full.pyi]
20502050

test-data/unit/check-typevar-tuple.test

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,7 @@ reveal_type(empty) # N: Revealed type is "__main__.Variadic[()]"
123123
omitted: Variadic
124124
reveal_type(omitted) # N: Revealed type is "__main__.Variadic[Unpack[builtins.tuple[Any, ...]]]"
125125

126-
bad: Variadic[Unpack[Tuple[int, ...]], str, Unpack[Tuple[bool, ...]]] # E: More than one variable Unpack in a type is not allowed
126+
bad: Variadic[Unpack[Tuple[int, ...]], str, Unpack[Tuple[bool, ...]]] # E: More than one variadic Unpack in a type is not allowed
127127
reveal_type(bad) # N: Revealed type is "__main__.Variadic[Unpack[builtins.tuple[builtins.int, ...]], builtins.str]"
128128

129129
bad2: Unpack[Tuple[int, ...]] # E: Unpack is only valid in a variadic position
@@ -353,12 +353,12 @@ expect_variadic_array_2(u)
353353
Ts = TypeVarTuple("Ts")
354354
Ts2 = TypeVarTuple("Ts2")
355355

356-
def bad(x: Tuple[int, Unpack[Ts], str, Unpack[Ts2]]) -> None: # E: More than one variable Unpack in a type is not allowed
356+
def bad(x: Tuple[int, Unpack[Ts], str, Unpack[Ts2]]) -> None: # E: More than one variadic Unpack in a type is not allowed
357357

358358
...
359359
reveal_type(bad) # N: Revealed type is "def [Ts, Ts2] (x: tuple[builtins.int, Unpack[Ts`-1], builtins.str])"
360360

361-
def bad2(x: Tuple[int, Unpack[Tuple[int, ...]], str, Unpack[Tuple[str, ...]]]) -> None: # E: More than one variable Unpack in a type is not allowed
361+
def bad2(x: Tuple[int, Unpack[Tuple[int, ...]], str, Unpack[Tuple[str, ...]]]) -> None: # E: More than one variadic Unpack in a type is not allowed
362362
...
363363
reveal_type(bad2) # N: Revealed type is "def (x: tuple[builtins.int, Unpack[builtins.tuple[builtins.int, ...]], builtins.str])"
364364
[builtins fixtures/tuple.pyi]
@@ -571,7 +571,7 @@ from typing_extensions import Unpack, TypeVarTuple
571571

572572
Ts = TypeVarTuple("Ts")
573573
Us = TypeVarTuple("Us")
574-
a: Callable[[Unpack[Ts], Unpack[Us]], int] # E: More than one variable Unpack in a type is not allowed
574+
a: Callable[[Unpack[Ts], Unpack[Us]], int] # E: More than one variadic Unpack in a type is not allowed
575575
reveal_type(a) # N: Revealed type is "def [Ts, Us] (*Unpack[Ts`-1]) -> builtins.int"
576576
b: Callable[[Unpack], int] # E: Unpack[...] requires exactly one type argument
577577
reveal_type(b) # N: Revealed type is "def (*Any) -> builtins.int"
@@ -725,15 +725,15 @@ Ts = TypeVarTuple("Ts")
725725
Us = TypeVarTuple("Us")
726726
class G(Generic[Unpack[Ts]]): ...
727727

728-
A = Tuple[Unpack[Ts], Unpack[Us]] # E: More than one variable Unpack in a type is not allowed
728+
A = Tuple[Unpack[Ts], Unpack[Us]] # E: More than one variadic Unpack in a type is not allowed
729729
x: A[int, str]
730730
reveal_type(x) # N: Revealed type is "tuple[builtins.int, builtins.str]"
731731

732-
B = Callable[[Unpack[Ts], Unpack[Us]], int] # E: More than one variable Unpack in a type is not allowed
732+
B = Callable[[Unpack[Ts], Unpack[Us]], int] # E: More than one variadic Unpack in a type is not allowed
733733
y: B[int, str]
734734
reveal_type(y) # N: Revealed type is "def (builtins.int, builtins.str) -> builtins.int"
735735

736-
C = G[Unpack[Ts], Unpack[Us]] # E: More than one variable Unpack in a type is not allowed
736+
C = G[Unpack[Ts], Unpack[Us]] # E: More than one variadic Unpack in a type is not allowed
737737
z: C[int, str]
738738
reveal_type(z) # N: Revealed type is "__main__.G[builtins.int, builtins.str]"
739739
[builtins fixtures/tuple.pyi]
@@ -2223,12 +2223,12 @@ cb2(1, 2, 3, a="a", b="b")
22232223
cb2(1, a="a", b="b") # E: Too few arguments
22242224
cb2(1, 2, 3, a="a") # E: Missing named argument "b"
22252225

2226-
bad1: Callable[[Unpack[Ints], Unpack[Ints]], None] # E: More than one variable Unpack in a type is not allowed
2226+
bad1: Callable[[Unpack[Ints], Unpack[Ints]], None] # E: More than one variadic Unpack in a type is not allowed
22272227
reveal_type(bad1) # N: Revealed type is "def (*builtins.int)"
22282228
bad2: Callable[[Unpack[Keywords], Unpack[Keywords]], None] # E: "Keywords" cannot be unpacked (must be tuple or TypeVarTuple)
22292229
reveal_type(bad2) # N: Revealed type is "def (*Any, **Unpack[TypedDict('__main__.Keywords', {'a': builtins.str, 'b': builtins.str})])"
22302230
bad3: Callable[[Unpack[Keywords], Unpack[Ints]], None] # E: "Keywords" cannot be unpacked (must be tuple or TypeVarTuple) \
2231-
# E: More than one variable Unpack in a type is not allowed
2231+
# E: More than one variadic Unpack in a type is not allowed
22322232
reveal_type(bad3) # N: Revealed type is "def (*Any)"
22332233
[builtins fixtures/dict.pyi]
22342234
[typing fixtures/typing-typeddict.pyi]

0 commit comments

Comments
 (0)