Skip to content

Commit e4d02a4

Browse files
committed
Address review
1 parent 88fec70 commit e4d02a4

File tree

1 file changed

+17
-15
lines changed

1 file changed

+17
-15
lines changed

mypy/expandtype.py

+17-15
Original file line numberDiff line numberDiff line change
@@ -307,22 +307,24 @@ def interpolate_args_for_unpack(self, t: CallableType, var_arg: UnpackType) -> l
307307
suffix = self.expand_types(t.arg_types[star_index + 1 :])
308308

309309
var_arg_type = get_proper_type(var_arg.type)
310-
if isinstance(var_arg_type, TupleType):
311-
# We have something like Unpack[Tuple[Unpack[Ts], X1, X2]]
312-
expanded_tuple = var_arg_type.accept(self)
313-
assert isinstance(expanded_tuple, ProperType) and isinstance(expanded_tuple, TupleType)
314-
expanded_items = expanded_tuple.items
315-
fallback = var_arg_type.partial_fallback
316-
elif isinstance(var_arg_type, Instance):
317-
# We have something like Unpack[Tuple[Any, ...]]
318-
expanded_items = list(var_arg_type.args)
319-
fallback = var_arg_type
310+
if isinstance(var_arg_type, Instance):
311+
# we have something like Unpack[Tuple[Any, ...]]
312+
new_unpack = var_arg
320313
else:
321-
# We have plain Unpack[Ts]
322-
assert isinstance(var_arg_type, TypeVarTupleType), type(var_arg_type)
323-
fallback = var_arg_type.tuple_fallback
324-
expanded_items = self.expand_unpack(var_arg)
325-
new_unpack = UnpackType(TupleType(expanded_items, fallback))
314+
if isinstance(var_arg_type, TupleType):
315+
# We have something like Unpack[Tuple[Unpack[Ts], X1, X2]]
316+
expanded_tuple = var_arg_type.accept(self)
317+
assert isinstance(expanded_tuple, ProperType) and isinstance(
318+
expanded_tuple, TupleType
319+
)
320+
expanded_items = expanded_tuple.items
321+
fallback = var_arg_type.partial_fallback
322+
else:
323+
# We have plain Unpack[Ts]
324+
assert isinstance(var_arg_type, TypeVarTupleType), type(var_arg_type)
325+
fallback = var_arg_type.tuple_fallback
326+
expanded_items = self.expand_unpack(var_arg)
327+
new_unpack = UnpackType(TupleType(expanded_items, fallback))
326328
return prefix + [new_unpack] + suffix
327329

328330
def visit_callable_type(self, t: CallableType) -> CallableType:

0 commit comments

Comments
 (0)