3030 freshen_all_functions_type_vars ,
3131 freshen_function_type_vars ,
3232)
33- from mypy .exprtotype import expr_to_unanalyzed_type , TypeTranslationError
33+ from mypy .exprtotype import TypeTranslationError , expr_to_unanalyzed_type
3434from mypy .infer import ArgumentInferContext , infer_function_type_arguments , infer_type_arguments
3535from mypy .literals import literal
3636from mypy .maptype import map_instance_to_supertype
4747 LITERAL_TYPE ,
4848 REVEAL_LOCALS ,
4949 REVEAL_TYPE ,
50+ UNBOUND_IMPORTED ,
5051 ArgKind ,
5152 AssertTypeExpr ,
5253 AssignmentExpr ,
6768 FloatExpr ,
6869 FuncDef ,
6970 GeneratorExpr ,
70- get_member_expr_fullname ,
7171 IndexExpr ,
7272 IntExpr ,
7373 LambdaExpr ,
105105 TypeVarExpr ,
106106 TypeVarTupleExpr ,
107107 UnaryExpr ,
108- UNBOUND_IMPORTED ,
109108 Var ,
110109 YieldExpr ,
111110 YieldFromExpr ,
111+ get_member_expr_fullname ,
112112)
113113from mypy .options import PRECISE_TUPLE_TYPES
114114from mypy .plugin import (
127127 is_subtype ,
128128 non_method_protocol_members ,
129129)
130- from mypy .traverser import all_name_and_member_expressions , has_await_expression , has_str_expression
130+ from mypy .traverser import (
131+ all_name_and_member_expressions ,
132+ has_await_expression ,
133+ has_str_expression ,
134+ )
131135from mypy .tvar_scope import TypeVarLikeScope
132136from mypy .typeanal import (
137+ TypeAnalyser ,
133138 check_for_explicit_any ,
134139 fix_instance ,
135140 has_any_from_unimported_type ,
136141 instantiate_type_alias ,
137142 make_optional_type ,
138143 set_any_tvars ,
139- TypeAnalyser ,
140144 validate_instance ,
141145)
142146from mypy .typeops import (
@@ -6335,17 +6339,19 @@ def try_parse_as_type_expression(self, maybe_type_expr: Expression) -> Type | No
63356339 # Check whether has already been parsed as a type expression
63366340 # by SemanticAnalyzer.try_parse_as_type_expression(),
63376341 # perhaps containing a string annotation
6338- if (isinstance (maybe_type_expr , (StrExpr , IndexExpr , OpExpr ))
6339- and maybe_type_expr .as_type is not Ellipsis ):
6342+ if (
6343+ isinstance (maybe_type_expr , (StrExpr , IndexExpr , OpExpr ))
6344+ and maybe_type_expr .as_type is not Ellipsis
6345+ ):
63406346 return maybe_type_expr .as_type
63416347
63426348 # If is potentially a type expression containing a string annotation,
63436349 # don't try to parse it because there isn't enough information
63446350 # available to the TypeChecker pass to resolve string annotations
63456351 if has_str_expression (maybe_type_expr ):
63466352 self .chk .note (
6347- ' TypeForm containing a string annotation cannot be recognized here. '
6348- ' Try assigning the TypeForm to a variable and use the variable here instead.' ,
6353+ " TypeForm containing a string annotation cannot be recognized here. "
6354+ " Try assigning the TypeForm to a variable and use the variable here instead." ,
63496355 maybe_type_expr ,
63506356 )
63516357 return None
@@ -6354,13 +6360,8 @@ def try_parse_as_type_expression(self, maybe_type_expr: Expression) -> Type | No
63546360 # to be looked up by TypeAnalyser when binding the
63556361 # UnboundTypes corresponding to those expressions.
63566362 (name_exprs , member_exprs ) = all_name_and_member_expressions (maybe_type_expr )
6357- sym_for_name = {
6358- e .name :
6359- SymbolTableNode (UNBOUND_IMPORTED , e .node )
6360- for e in name_exprs
6361- } | {
6362- e_name :
6363- SymbolTableNode (UNBOUND_IMPORTED , e .node )
6363+ sym_for_name = {e .name : SymbolTableNode (UNBOUND_IMPORTED , e .node ) for e in name_exprs } | {
6364+ e_name : SymbolTableNode (UNBOUND_IMPORTED , e .node )
63646365 for e in member_exprs
63656366 if (e_name := get_member_expr_fullname (e )) is not None
63666367 }
@@ -6377,7 +6378,7 @@ def try_parse_as_type_expression(self, maybe_type_expr: Expression) -> Type | No
63776378
63786379 try :
63796380 typ1 = expr_to_unanalyzed_type (
6380- maybe_type_expr , self .chk .options , self .chk .is_typeshed_stub ,
6381+ maybe_type_expr , self .chk .options , self .chk .is_typeshed_stub
63816382 )
63826383 typ2 = typ1 .accept (tpan )
63836384 if chk_sem .did_fail :
0 commit comments