@@ -7843,8 +7843,9 @@ def try_parse_as_type_expression(self, maybe_type_expr: Expression) -> None:
78437843 return
78447844 elif isinstance (maybe_type_expr , IndexExpr ):
78457845 if isinstance (maybe_type_expr .base , NameExpr ):
7846- if (isinstance (maybe_type_expr .base .node , Var ) and
7847- not self .var_is_typing_special_form (maybe_type_expr .base )):
7846+ if isinstance (
7847+ maybe_type_expr .base .node , Var
7848+ ) and not self .var_is_typing_special_form (maybe_type_expr .base ):
78487849 # Leftmost part of IndexExpr refers to a Var. Not a valid type.
78497850 maybe_type_expr .as_type = None
78507851 return
@@ -7856,8 +7857,9 @@ def try_parse_as_type_expression(self, maybe_type_expr: Expression) -> None:
78567857 break
78577858 next_leftmost = leftmost
78587859 if isinstance (leftmost , NameExpr ):
7859- if (isinstance (leftmost .node , Var ) and
7860- not self .var_is_typing_special_form (leftmost .node )):
7860+ if isinstance (leftmost .node , Var ) and not self .var_is_typing_special_form (
7861+ leftmost .node
7862+ ):
78617863 # Leftmost part of IndexExpr refers to a Var. Not a valid type.
78627864 maybe_type_expr .as_type = None
78637865 return
@@ -7907,18 +7909,19 @@ def try_parse_as_type_expression(self, maybe_type_expr: Expression) -> None:
79077909
79087910 @staticmethod
79097911 def var_is_typing_special_form (var : Var ) -> bool :
7910- return (
7911- var .fullname .startswith ('typing' ) and
7912- var .fullname in [
7913- 'typing.Annotated' , 'typing_extensions.Annotated' ,
7914- 'typing.Callable' ,
7915- 'typing.Literal' , 'typing_extensions.Literal' ,
7916- 'typing.Optional' ,
7917- 'typing.TypeGuard' , 'typing_extensions.TypeGuard' ,
7918- 'typing.TypeIs' , 'typing_extensions.TypeIs' ,
7919- 'typing.Union' ,
7920- ]
7921- )
7912+ return var .fullname .startswith ("typing" ) and var .fullname in [
7913+ "typing.Annotated" ,
7914+ "typing_extensions.Annotated" ,
7915+ "typing.Callable" ,
7916+ "typing.Literal" ,
7917+ "typing_extensions.Literal" ,
7918+ "typing.Optional" ,
7919+ "typing.TypeGuard" ,
7920+ "typing_extensions.TypeGuard" ,
7921+ "typing.TypeIs" ,
7922+ "typing_extensions.TypeIs" ,
7923+ "typing.Union" ,
7924+ ]
79227925
79237926 @contextmanager
79247927 def isolated_error_analysis (self ) -> Iterator [None ]:
0 commit comments