File tree Expand file tree Collapse file tree 1 file changed +13
-3
lines changed Expand file tree Collapse file tree 1 file changed +13
-3
lines changed Original file line number Diff line number Diff line change @@ -6074,7 +6074,9 @@ def visit_type_application(self, expr: TypeApplication) -> None:
60746074 if analyzed is not None :
60756075 expr .types [i ] = analyzed
60766076
6077- def _check_await_outside_coroutine (self , expr : ListComprehension | SetComprehension | DictionaryComprehension ) -> None :
6077+ def _check_await_outside_coroutine (
6078+ self , expr : ListComprehension | SetComprehension | DictionaryComprehension
6079+ ) -> None :
60786080 if not has_await_expression (expr ):
60796081 return
60806082
@@ -6195,8 +6197,16 @@ def visit_await_expr(self, expr: AwaitExpr) -> None:
61956197 # We check both because is_function_scope() returns True inside comprehensions.
61966198 # This is not a blocker, because some enviroments (like ipython)
61976199 # support top level awaits.
6198- self .fail (message_registry .AWAIT_OUTSIDE_FUNCTION , expr , serious = True , code = codes .TOP_LEVEL_AWAIT )
6199- elif not self .function_stack [- 1 ].is_coroutine and self .scope_stack [- 1 ] != SCOPE_COMPREHENSION :
6200+ self .fail (
6201+ message_registry .AWAIT_OUTSIDE_FUNCTION ,
6202+ expr ,
6203+ serious = True ,
6204+ code = codes .TOP_LEVEL_AWAIT ,
6205+ )
6206+ elif (
6207+ not self .function_stack [- 1 ].is_coroutine
6208+ and self .scope_stack [- 1 ] != SCOPE_COMPREHENSION
6209+ ):
62006210 self .fail (
62016211 message_registry .AWAIT_OUTSIDE_COROUTINE ,
62026212 expr ,
You can’t perform that action at this time.
0 commit comments