@@ -551,31 +551,33 @@ def visit_call_expr_inner(self, e: CallExpr, allow_none_return: bool = False) ->
551
551
):
552
552
# Special hanlding for get_args(), returns a typed tuple
553
553
# with the type set by the input
554
- typ = None
554
+ argtyp = None
555
555
if isinstance (e .args [0 ], IndexExpr ):
556
556
self .accept (e .args [0 ].index )
557
- typ = self .chk .lookup_type (e .args [0 ].index )
558
- else :
557
+ argtyp = self .chk .lookup_type (e .args [0 ].index )
558
+ elif isinstance ( e . args [ 0 ], NameExpr ) :
559
559
try :
560
560
node = self .chk .lookup_qualified (e .args [0 ].name )
561
561
if node :
562
562
if isinstance (node .node , TypeAlias ):
563
563
# Resolve type
564
- typ = get_proper_type ( node .node .target )
565
- else :
566
- typ = node .node .type
564
+ argtyp = node .node .target
565
+ elif isinstance ( node . node , Var ) :
566
+ argtyp = node .node .type
567
567
except KeyError :
568
568
# Undefined names should already be reported in semantic analysis.
569
569
pass
570
+ if argtyp is not None :
571
+ argtyp = get_proper_type (argtyp )
570
572
if (
571
- typ is not None
572
- and isinstance (typ , UnionType )
573
- and all (isinstance (t , LiteralType ) for t in typ .items )
573
+ argtyp is not None
574
+ and isinstance (argtyp , UnionType )
575
+ and all (isinstance (get_proper_type ( t ) , LiteralType ) for t in argtyp .items )
574
576
):
575
577
# Returning strings is defined but order isn't so
576
578
# we need to return type * len of the union
577
579
return TupleType (
578
- [typ ] * len (typ .items ), fallback = self .named_type ("builtins.tuple" )
580
+ [argtyp ] * len (argtyp .items ), fallback = self .named_type ("builtins.tuple" )
579
581
)
580
582
else :
581
583
# Fall back to what we did anyway (Tuple[Any])
0 commit comments