@@ -1112,7 +1112,6 @@ def visit_callable_type(
1112
1112
return ret
1113
1113
1114
1114
def anal_type_guard (self , t : Type ) -> Type | None :
1115
- t = t .resolve_string_annotation ()
1116
1115
if isinstance (t , UnboundType ):
1117
1116
sym = self .lookup_qualified (t .name , t )
1118
1117
if sym is not None and sym .node is not None :
@@ -1131,7 +1130,6 @@ def anal_type_guard_arg(self, t: UnboundType, fullname: str) -> Type | None:
1131
1130
return None
1132
1131
1133
1132
def anal_type_is (self , t : Type ) -> Type | None :
1134
- t = t .resolve_string_annotation ()
1135
1133
if isinstance (t , UnboundType ):
1136
1134
sym = self .lookup_qualified (t .name , t )
1137
1135
if sym is not None and sym .node is not None :
@@ -1149,7 +1147,6 @@ def anal_type_is_arg(self, t: UnboundType, fullname: str) -> Type | None:
1149
1147
1150
1148
def anal_star_arg_type (self , t : Type , kind : ArgKind , nested : bool ) -> Type :
1151
1149
"""Analyze signature argument type for *args and **kwargs argument."""
1152
- t = t .resolve_string_annotation ()
1153
1150
if isinstance (t , UnboundType ) and t .name and "." in t .name and not t .args :
1154
1151
components = t .name .split ("." )
1155
1152
tvar_name = "." .join (components [:- 1 ])
@@ -1275,8 +1272,6 @@ def visit_raw_expression_type(self, t: RawExpressionType) -> Type:
1275
1272
# make signatures like "foo(x: 20) -> None" legal, we can change
1276
1273
# this method so it generates and returns an actual LiteralType
1277
1274
# instead.
1278
- if t .node is not None :
1279
- return t .node .accept (self )
1280
1275
1281
1276
if self .report_invalid_types :
1282
1277
if t .base_type_name in ("builtins.int" , "builtins.bool" ):
@@ -1539,7 +1534,6 @@ def analyze_callable_args(
1539
1534
invalid_unpacks : list [Type ] = []
1540
1535
second_unpack_last = False
1541
1536
for i , arg in enumerate (arglist .items ):
1542
- arg = arg .resolve_string_annotation ()
1543
1537
if isinstance (arg , CallableArgument ):
1544
1538
args .append (arg .typ )
1545
1539
names .append (arg .name )
@@ -1620,6 +1614,18 @@ def analyze_literal_type(self, t: UnboundType) -> Type:
1620
1614
return UnionType .make_union (output , line = t .line )
1621
1615
1622
1616
def analyze_literal_param (self , idx : int , arg : Type , ctx : Context ) -> list [Type ] | None :
1617
+ # This UnboundType was originally defined as a string.
1618
+ if isinstance (arg , UnboundType ) and arg .original_str_expr is not None :
1619
+ assert arg .original_str_fallback is not None
1620
+ return [
1621
+ LiteralType (
1622
+ value = arg .original_str_expr ,
1623
+ fallback = self .named_type (arg .original_str_fallback ),
1624
+ line = arg .line ,
1625
+ column = arg .column ,
1626
+ )
1627
+ ]
1628
+
1623
1629
# If arg is an UnboundType that was *not* originally defined as
1624
1630
# a string, try expanding it in case it's a type alias or something.
1625
1631
if isinstance (arg , UnboundType ):
@@ -2605,8 +2611,7 @@ def visit_typeddict_type(self, t: TypedDictType) -> None:
2605
2611
self .process_types (list (t .items .values ()))
2606
2612
2607
2613
def visit_raw_expression_type (self , t : RawExpressionType ) -> None :
2608
- if t .node is not None :
2609
- t .node .accept (self )
2614
+ pass
2610
2615
2611
2616
def visit_literal_type (self , t : LiteralType ) -> None :
2612
2617
pass
0 commit comments