Skip to content

Commit

Permalink
[pre-commit.ci] auto fixes from pre-commit.com hooks
Browse files Browse the repository at this point in the history
for more information, see https://pre-commit.ci
  • Loading branch information
pre-commit-ci[bot] committed Nov 14, 2024
1 parent 0c82fb9 commit 8e8298e
Showing 1 changed file with 13 additions and 3 deletions.
16 changes: 13 additions & 3 deletions mypy/semanal.py
Original file line number Diff line number Diff line change
Expand Up @@ -6074,7 +6074,9 @@ def visit_type_application(self, expr: TypeApplication) -> None:
if analyzed is not None:
expr.types[i] = analyzed

def _check_await_outside_coroutine(self, expr: ListComprehension | SetComprehension | DictionaryComprehension) -> None:
def _check_await_outside_coroutine(
self, expr: ListComprehension | SetComprehension | DictionaryComprehension
) -> None:
if not has_await_expression(expr):
return

Expand Down Expand Up @@ -6195,8 +6197,16 @@ def visit_await_expr(self, expr: AwaitExpr) -> None:
# We check both because is_function_scope() returns True inside comprehensions.
# This is not a blocker, because some enviroments (like ipython)
# support top level awaits.
self.fail(message_registry.AWAIT_OUTSIDE_FUNCTION, expr, serious=True, code=codes.TOP_LEVEL_AWAIT)
elif not self.function_stack[-1].is_coroutine and self.scope_stack[-1] != SCOPE_COMPREHENSION:
self.fail(
message_registry.AWAIT_OUTSIDE_FUNCTION,
expr,
serious=True,
code=codes.TOP_LEVEL_AWAIT,
)
elif (
not self.function_stack[-1].is_coroutine
and self.scope_stack[-1] != SCOPE_COMPREHENSION
):
self.fail(
message_registry.AWAIT_OUTSIDE_COROUTINE,
expr,
Expand Down

0 comments on commit 8e8298e

Please sign in to comment.