Skip to content

Commit

Permalink
chore: error type is not syntax but await-not-async
Browse files Browse the repository at this point in the history
  • Loading branch information
josetapadas committed Nov 13, 2024
1 parent 43fc65a commit e3004a1
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 deletions.
2 changes: 1 addition & 1 deletion mypy/semanal.py
Original file line number Diff line number Diff line change
Expand Up @@ -6088,7 +6088,7 @@ def visit_list_comprehension(self, expr: ListComprehension) -> None:
self.fail(
message_registry.AWAIT_WITH_OUTSIDE_COROUTINE,
expr,
code=codes.SYNTAX,
code=codes.AWAIT_NOT_ASYNC,
serious=True,
)

Expand Down
5 changes: 3 additions & 2 deletions test-data/unit/check-async-await.test
Original file line number Diff line number Diff line change
Expand Up @@ -1013,16 +1013,17 @@ async def foo(x: int) -> int: ...

# These are allowed in some cases:
top_level = await foo(1) # E: "await" outside function [top-level-await]
crasher = [await foo(x) for x in [1, 2, 3]] # E: "await" outside coroutine ("async def") [syntax] \
crasher = [await foo(x) for x in [1, 2, 3]] # E: "await" outside coroutine ("async def") [await-not-async] \
# E: "await" outside function [top-level-await]

def bad() -> None:
# These are always critical / syntax issues:
y = [await foo(x) for x in [1, 2, 3]] # E: "await" outside coroutine ("async def") [syntax]
y = [await foo(x) for x in [1, 2, 3]] # E: "await" outside coroutine ("async def") [await-not-async]
async def good() -> None:
y = [await foo(x) for x in [1, 2, 3]] # OK



[builtins fixtures/async_await.pyi]
[typing fixtures/typing-async.pyi]

Expand Down

0 comments on commit e3004a1

Please sign in to comment.