mirror of
https://github.com/astral-sh/ruff.git
synced 2025-08-04 18:58:04 +00:00
[syntax-errors] await
outside async functions (#17363)
Summary -- This PR implements detecting the use of `await` expressions outside of async functions. This is a reimplementation of [await-outside-async (PLE1142)](https://docs.astral.sh/ruff/rules/await-outside-async/) as a semantic syntax error. Despite the rule name, PLE1142 also applies to `async for` and `async with`, so these are covered here too. Test Plan -- Existing PLE1142 tests. I also deleted more code from the `SemanticSyntaxCheckerVisitor` to avoid changes in other parser tests.
This commit is contained in:
parent
e2a38e4c00
commit
014bb526f4
9 changed files with 186 additions and 89 deletions
|
@ -72,3 +72,15 @@ def await_generator_target():
|
|||
# See: https://github.com/astral-sh/ruff/issues/14167
|
||||
def async_for_list_comprehension_target():
|
||||
[x for x in await foo()]
|
||||
|
||||
|
||||
def async_for_dictionary_comprehension_key():
|
||||
{await x: y for x, y in foo()}
|
||||
|
||||
|
||||
def async_for_dictionary_comprehension_value():
|
||||
{y: await x for x, y in foo()}
|
||||
|
||||
|
||||
def async_for_dict_comprehension():
|
||||
{x: y async for x, y in foo()}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue