An async function never awaits anything
What it finds
async def load(path): without any await, async for or async with in its body: the function never gives control back to the event loop, so making it a coroutine only costs callers an await and hides that it blocks while it runs.
Left alone are methods and functions with decorators, which may have to be coroutines to fit an interface, async generators, and bodies that are only a docstring, pass, ... or a raise, as stubs and abstract methods are.
From the rule's source, async_without_await.rs.
import asyncio async def load(path):tx0 reports: load is async but never awaits return open(path).read() async def fetch(client): return await client.get() async def stream(items): for item in items: yield item async def stub(): ... async def iterate(source): async for item in source: return item Turn it on, off or suppress it
The rule runs from the strict tier up. To turn it on in a lower tier, give it a level in tx0.toml:
[rules]
"tx0/python:async-without-await" = "warning"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:async-without-await] reason="..."tx0 explain tx0/python:async-without-await shows the same in the terminal. Found a false positive? Report it.