---
source: crates/ruff_linter/src/rules/pylint/mod.rs
---
await_outside_async.py:15:11: PLE1142 `await` should be used within an async function
   |
14 | def not_async():
15 |     print(await nested())  # [await-outside-async]
   |           ^^^^^^^^^^^^^^ PLE1142
   |

await_outside_async.py:29:9: PLE1142 `await` should be used within an async function
   |
27 | async def func2():
28 |     def inner_func():
29 |         await asyncio.sleep(1)  # [await-outside-async]
   |         ^^^^^^^^^^^^^^^^^^^^^^ PLE1142
   |

await_outside_async.py:38:5: PLE1142 `await` should be used within an async function
   |
37 |   def async_for_loop():
38 | /     async for x in foo():
39 | |         pass
   | |____________^ PLE1142
   |

await_outside_async.py:43:5: PLE1142 `await` should be used within an async function
   |
42 |   def async_with():
43 | /     async with foo():
44 | |         pass
   | |____________^ PLE1142
   |

await_outside_async.py:54:6: PLE1142 `await` should be used within an async function
   |
52 | # See: https://github.com/astral-sh/ruff/issues/14167
53 | def async_for_list_comprehension_elt():
54 |     [await x for x in foo()]
   |      ^^^^^^^ PLE1142
   |

await_outside_async.py:59:8: PLE1142 `await` should be used within an async function
   |
57 | # See: https://github.com/astral-sh/ruff/issues/14167
58 | def async_for_list_comprehension():
59 |     [x async for x in foo()]
   |        ^^^^^^^^^^^^^^^^^^^^ PLE1142
   |

await_outside_async.py:64:17: PLE1142 `await` should be used within an async function
   |
62 | # See: https://github.com/astral-sh/ruff/issues/14167
63 | def await_generator_iter():
64 |     (x for x in await foo())
   |                 ^^^^^^^^^^^ PLE1142
   |

await_outside_async.py:74:17: PLE1142 `await` should be used within an async function
   |
72 | # See: https://github.com/astral-sh/ruff/issues/14167
73 | def async_for_list_comprehension_target():
74 |     [x for x in await foo()]
   |                 ^^^^^^^^^^^ PLE1142
   |
