@@ -271,10 +271,11 @@ def interpolate_args_for_unpack(
271271 star_index = t .arg_kinds .index (ARG_STAR )
272272
273273 # We have something like Unpack[Tuple[X1, X2, Unpack[Ts], Y1, Y2]]
274- if isinstance (get_proper_type (var_arg .type ), TupleType ):
275- expanded_tuple = get_proper_type (var_arg .type .accept (self ))
274+ var_arg_type = get_proper_type (var_arg .type )
275+ if isinstance (var_arg_type , TupleType ):
276+ expanded_tuple = var_arg_type .accept (self )
276277 # TODO: handle the case that expanded_tuple is a variable length tuple.
277- assert isinstance (expanded_tuple , TupleType )
278+ assert isinstance (expanded_tuple , ProperType ) and isinstance ( expanded_tuple , TupleType )
278279 expanded_items = expanded_tuple .items
279280 else :
280281 expanded_items_res = self .expand_unpack (var_arg )
@@ -320,11 +321,11 @@ def interpolate_args_for_unpack(
320321 # homogenous tuple, then only the prefix can be represented as
321322 # positional arguments, and we pass Tuple[Unpack[Ts-1], Y1, Y2]
322323 # as the star arg, for example.
323- expanded_unpack = get_proper_type ( expanded_items [expanded_unpack_index ])
324+ expanded_unpack = expanded_items [expanded_unpack_index ]
324325 assert isinstance (expanded_unpack , UnpackType )
325326
326327 # Extract the typevartuple so we can get a tuple fallback from it.
327- expanded_unpacked_tvt = get_proper_type ( expanded_unpack .type )
328+ expanded_unpacked_tvt = expanded_unpack .type
328329 assert isinstance (expanded_unpacked_tvt , TypeVarTupleType )
329330
330331 prefix_len = expanded_unpack_index
@@ -450,18 +451,14 @@ def visit_tuple_type(self, t: TupleType) -> Type:
450451 items = self .expand_types_with_unpack (t .items )
451452 if isinstance (items , list ):
452453 fallback = t .partial_fallback .accept (self )
453- fallback = get_proper_type (fallback )
454- if not isinstance (fallback , Instance ):
455- fallback = t .partial_fallback
454+ assert isinstance (fallback , ProperType ) and isinstance (fallback , Instance )
456455 return t .copy_modified (items = items , fallback = fallback )
457456 else :
458457 return items
459458
460459 def visit_typeddict_type (self , t : TypedDictType ) -> Type :
461460 fallback = t .fallback .accept (self )
462- fallback = get_proper_type (fallback )
463- if not isinstance (fallback , Instance ):
464- fallback = t .fallback
461+ assert isinstance (fallback , ProperType ) and isinstance (fallback , Instance )
465462 return t .copy_modified (item_types = self .expand_types (t .items .values ()), fallback = fallback )
466463
467464 def visit_literal_type (self , t : LiteralType ) -> Type :
0 commit comments