A coroutine is created by a call and dropped without being awaited
What it finds
asyncio.sleep(1) or save(record) on a line of its own, where save is an async def: calling a coroutine function only makes a coroutine object, and nothing runs until it is awaited. Python warns coroutine ... was never awaited when the object is collected, long after the line that forgot the await.
Reported are expression statements that call asyncio.sleep, asyncio.wait_for, asyncio.wait or asyncio.open_connection, or a function of this file defined once with async def and without decorators, outside a function nested in it.
From the rule's source, coroutine_not_awaited.rs.
import asyncio async def save(record): await asyncio.sleep(0) async def main(record): asyncio.sleep(1)tx0 reports: asyncio.sleep(...) makes a coroutine that is never awaited, so it never runs save(record)tx0 reports: save(...) makes a coroutine that is never awaited await save(record) await asyncio.sleep(1) task = asyncio.create_task(save(record)) await task Turn it on, off or suppress it
The rule runs in every tier. To turn it off for a project, set its level in tx0.toml:
[rules]
"tx0/python:coroutine-not-awaited" = "off"To keep one finding, suppress it with a reason. tx0 suppress ID --reason "..." writes the comment on the line before the code:
# tx0: ignore[tx0/python:coroutine-not-awaited] reason="..."tx0 explain tx0/python:coroutine-not-awaited shows the same in the terminal. Found a false positive? Report it.