A task group or nursery starts only one task, which awaiting the coroutine directly does without the group

tx0/python:single-task-groupallnotestyle/conventionsdepth faststyle

What it finds

async with asyncio.TaskGroup() as tg: tg.create_task(work()) runs one task and waits for it, the same as await work(), with more machinery and a harder traceback. Groups pay off with several concurrent tasks.

From the rule's source, single_task_group.rs.

Example from the rule's tests
import asyncio async def main():    async with asyncio.TaskGroup() as tg:tx0 reports: a group that starts one task is the same as awaiting it        tg.create_task(work())    async with asyncio.TaskGroup() as tg:        tg.create_task(work())        tg.create_task(work())
Highlighted lines are the ones tx0 reports, with its message under each; the other lines are left alone.

Turn it on, off or suppress it

The rule runs from the all tier up. To turn it on in a lower tier, give it a level in tx0.toml:

tx0.toml
[rules]
"tx0/python:single-task-group" = "note"

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:single-task-group] reason="..."

tx0 explain tx0/python:single-task-group shows the same in the terminal. Found a false positive? Report it.