Skip to content

Commit 08267d5

Browse files
committed
chore: refactor to remove function for simple check
1 parent 271b94d commit 08267d5

File tree

1 file changed

+1
-6
lines changed

1 file changed

+1
-6
lines changed

mypy/semanal.py

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6178,9 +6178,7 @@ def visit_await_expr(self, expr: AwaitExpr) -> None:
61786178
# This is not a blocker, because some enviroments (like ipython)
61796179
# support top level awaits.
61806180
self.fail('"await" outside function', expr, serious=True, code=codes.TOP_LEVEL_AWAIT)
6181-
elif not self.function_stack[-1].is_coroutine and not self.is_in_generator_expression(
6182-
expr
6183-
):
6181+
elif not self.function_stack[-1].is_coroutine and self.scope_stack[-1] != SCOPE_COMPREHENSION:
61846182
self.fail(
61856183
'"await" outside coroutine ("async def")',
61866184
expr,
@@ -6189,9 +6187,6 @@ def visit_await_expr(self, expr: AwaitExpr) -> None:
61896187
)
61906188
expr.expr.accept(self)
61916189

6192-
def is_in_generator_expression(self, node: AwaitExpr):
6193-
return self.scope_stack[-1] == SCOPE_COMPREHENSION
6194-
61956190
#
61966191
# Patterns
61976192
#

0 commit comments

Comments
 (0)