Skip to content

Commit f69d3e3

Browse files
committed
Fix prefix/suffix support
1 parent 895d53d commit f69d3e3

File tree

2 files changed

+6
-5
lines changed

2 files changed

+6
-5
lines changed

mypy/subtypes.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -351,8 +351,8 @@ def check_mixed(
351351
unpack_index = right.type.type_var_tuple_prefix
352352
assert unpack_index is not None
353353
type_params = zip(
354-
left_prefix + right_prefix,
355-
left_suffix + right_suffix,
354+
left_prefix + right_suffix,
355+
right_prefix + right_suffix,
356356
right.type.defn.type_vars[:unpack_index] +
357357
right.type.defn.type_vars[unpack_index+1:]
358358
)

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

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -131,14 +131,15 @@ from typing_extensions import TypeVarTuple, Unpack
131131

132132
Ts = TypeVarTuple("Ts")
133133
T = TypeVar("T")
134+
S = TypeVar("S")
134135

135-
class Variadic(Generic[T, Ts]):
136+
class Variadic(Generic[T, Ts, S]):
136137
pass
137138

138-
def foo(t: Variadic[int, Unpack[Ts]]) -> Tuple[int, Unpack[Ts]]:
139+
def foo(t: Variadic[int, Unpack[Ts], object]) -> Tuple[int, Unpack[Ts]]:
139140
...
140141

141-
v: Variadic[int, str, bool]
142+
v: Variadic[int, str, bool, object]
142143
reveal_type(foo(v)) # N: Revealed type is "Tuple[builtins.int, builtins.str, builtins.bool]"
143144

144145
[builtins fixtures/tuple.pyi]

0 commit comments

Comments
 (0)