@@ -307,22 +307,24 @@ def interpolate_args_for_unpack(self, t: CallableType, var_arg: UnpackType) -> l
307
307
suffix = self .expand_types (t .arg_types [star_index + 1 :])
308
308
309
309
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
320
313
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 ))
326
328
return prefix + [new_unpack ] + suffix
327
329
328
330
def visit_callable_type (self , t : CallableType ) -> CallableType :
0 commit comments