@@ -1107,7 +1107,6 @@ def visit_callable_type(
11071107 return ret
11081108
11091109 def anal_type_guard (self , t : Type ) -> Type | None :
1110- t = t .resolve_string_annotation ()
11111110 if isinstance (t , UnboundType ):
11121111 sym = self .lookup_qualified (t .name , t )
11131112 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:
11261125 return None
11271126
11281127 def anal_type_is (self , t : Type ) -> Type | None :
1129- t = t .resolve_string_annotation ()
11301128 if isinstance (t , UnboundType ):
11311129 sym = self .lookup_qualified (t .name , t )
11321130 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:
11441142
11451143 def anal_star_arg_type (self , t : Type , kind : ArgKind , nested : bool ) -> Type :
11461144 """Analyze signature argument type for *args and **kwargs argument."""
1147- t = t .resolve_string_annotation ()
11481145 if isinstance (t , UnboundType ) and t .name and "." in t .name and not t .args :
11491146 components = t .name .split ("." )
11501147 tvar_name = "." .join (components [:- 1 ])
@@ -1235,8 +1232,6 @@ def visit_raw_expression_type(self, t: RawExpressionType) -> Type:
12351232 # make signatures like "foo(x: 20) -> None" legal, we can change
12361233 # this method so it generates and returns an actual LiteralType
12371234 # instead.
1238- if t .node is not None :
1239- return t .node .accept (self )
12401235
12411236 if self .report_invalid_types :
12421237 if t .base_type_name in ("builtins.int" , "builtins.bool" ):
@@ -1499,7 +1494,6 @@ def analyze_callable_args(
14991494 invalid_unpacks : list [Type ] = []
15001495 second_unpack_last = False
15011496 for i , arg in enumerate (arglist .items ):
1502- arg = arg .resolve_string_annotation ()
15031497 if isinstance (arg , CallableArgument ):
15041498 args .append (arg .typ )
15051499 names .append (arg .name )
@@ -1580,6 +1574,18 @@ def analyze_literal_type(self, t: UnboundType) -> Type:
15801574 return UnionType .make_union (output , line = t .line )
15811575
15821576 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+
15831589 # If arg is an UnboundType that was *not* originally defined as
15841590 # a string, try expanding it in case it's a type alias or something.
15851591 if isinstance (arg , UnboundType ):
@@ -2564,8 +2570,7 @@ def visit_typeddict_type(self, t: TypedDictType) -> None:
25642570 self .process_types (list (t .items .values ()))
25652571
25662572 def visit_raw_expression_type (self , t : RawExpressionType ) -> None :
2567- if t .node is not None :
2568- t .node .accept (self )
2573+ pass
25692574
25702575 def visit_literal_type (self , t : LiteralType ) -> None :
25712576 pass
0 commit comments