Skip to content

Commit e3004a1

Browse files
committed
chore: error type is not syntax but await-not-async
1 parent 43fc65a commit e3004a1

File tree

2 files changed

+4
-3
lines changed

2 files changed

+4
-3
lines changed

mypy/semanal.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6088,7 +6088,7 @@ def visit_list_comprehension(self, expr: ListComprehension) -> None:
60886088
self.fail(
60896089
message_registry.AWAIT_WITH_OUTSIDE_COROUTINE,
60906090
expr,
6091-
code=codes.SYNTAX,
6091+
code=codes.AWAIT_NOT_ASYNC,
60926092
serious=True,
60936093
)
60946094

test-data/unit/check-async-await.test

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1013,16 +1013,17 @@ async def foo(x: int) -> int: ...
10131013

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

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

10251025

1026+
10261027
[builtins fixtures/async_await.pyi]
10271028
[typing fixtures/typing-async.pyi]
10281029

0 commit comments

Comments
 (0)