@@ -1107,7 +1107,6 @@ def visit_callable_type(
1107
1107
return ret
1108
1108
1109
1109
def anal_type_guard (self , t : Type ) -> Type | None :
1110
- t = t .resolve_string_annotation ()
1111
1110
if isinstance (t , UnboundType ):
1112
1111
sym = self .lookup_qualified (t .name , t )
1113
1112
if sym is not None and sym .node is not None :
@@ -1126,7 +1125,6 @@ def anal_type_guard_arg(self, t: UnboundType, fullname: str) -> Type | None:
1126
1125
return None
1127
1126
1128
1127
def anal_type_is (self , t : Type ) -> Type | None :
1129
- t = t .resolve_string_annotation ()
1130
1128
if isinstance (t , UnboundType ):
1131
1129
sym = self .lookup_qualified (t .name , t )
1132
1130
if sym is not None and sym .node is not None :
@@ -1144,7 +1142,6 @@ def anal_type_is_arg(self, t: UnboundType, fullname: str) -> Type | None:
1144
1142
1145
1143
def anal_star_arg_type (self , t : Type , kind : ArgKind , nested : bool ) -> Type :
1146
1144
"""Analyze signature argument type for *args and **kwargs argument."""
1147
- t = t .resolve_string_annotation ()
1148
1145
if isinstance (t , UnboundType ) and t .name and "." in t .name and not t .args :
1149
1146
components = t .name .split ("." )
1150
1147
tvar_name = "." .join (components [:- 1 ])
@@ -1235,8 +1232,6 @@ def visit_raw_expression_type(self, t: RawExpressionType) -> Type:
1235
1232
# make signatures like "foo(x: 20) -> None" legal, we can change
1236
1233
# this method so it generates and returns an actual LiteralType
1237
1234
# instead.
1238
- if t .node is not None :
1239
- return t .node .accept (self )
1240
1235
1241
1236
if self .report_invalid_types :
1242
1237
if t .base_type_name in ("builtins.int" , "builtins.bool" ):
@@ -1499,7 +1494,6 @@ def analyze_callable_args(
1499
1494
invalid_unpacks : list [Type ] = []
1500
1495
second_unpack_last = False
1501
1496
for i , arg in enumerate (arglist .items ):
1502
- arg = arg .resolve_string_annotation ()
1503
1497
if isinstance (arg , CallableArgument ):
1504
1498
args .append (arg .typ )
1505
1499
names .append (arg .name )
@@ -1580,6 +1574,18 @@ def analyze_literal_type(self, t: UnboundType) -> Type:
1580
1574
return UnionType .make_union (output , line = t .line )
1581
1575
1582
1576
def analyze_literal_param (self , idx : int , arg : Type , ctx : Context ) -> list [Type ] | None :
1577
+ # This UnboundType was originally defined as a string.
1578
+ if isinstance (arg , UnboundType ) and arg .original_str_expr is not None :
1579
+ assert arg .original_str_fallback is not None
1580
+ return [
1581
+ LiteralType (
1582
+ value = arg .original_str_expr ,
1583
+ fallback = self .named_type (arg .original_str_fallback ),
1584
+ line = arg .line ,
1585
+ column = arg .column ,
1586
+ )
1587
+ ]
1588
+
1583
1589
# If arg is an UnboundType that was *not* originally defined as
1584
1590
# a string, try expanding it in case it's a type alias or something.
1585
1591
if isinstance (arg , UnboundType ):
@@ -2564,8 +2570,7 @@ def visit_typeddict_type(self, t: TypedDictType) -> None:
2564
2570
self .process_types (list (t .items .values ()))
2565
2571
2566
2572
def visit_raw_expression_type (self , t : RawExpressionType ) -> None :
2567
- if t .node is not None :
2568
- t .node .accept (self )
2573
+ pass
2569
2574
2570
2575
def visit_literal_type (self , t : LiteralType ) -> None :
2571
2576
pass
0 commit comments