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

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

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

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

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

PLE1142 `await` should be used within an async function
  --> await_outside_async.py:74:17
   |
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 `await` should be used within an async function
  --> await_outside_async.py:78:6
   |
77 | def async_for_dictionary_comprehension_key():
78 |     {await x: y for x, y in foo()}
   |      ^^^^^^^
   |

PLE1142 `await` should be used within an async function
  --> await_outside_async.py:82:9
   |
81 | def async_for_dictionary_comprehension_value():
82 |     {y: await x for x, y in foo()}
   |         ^^^^^^^
   |

PLE1142 `await` should be used within an async function
  --> await_outside_async.py:86:11
   |
85 | def async_for_dict_comprehension():
86 |     {x: y async for x, y in foo()}
   |           ^^^^^^^^^^^^^^^^^^^^^^^
   |
