Skip to content

Unused awaitable with TaskGroup #15036

Open
@Dreamsorcerer

Description

@Dreamsorcerer
import asyncio

async def main() -> None:
    async with asyncio.TaskGroup() as tg:
        tg.create_task(asyncio.sleep(1))

With unused-awaitable enabled, this code generates an unused awaitable error. TaskGroup is expected to wait on any created tasks, so there is no need to await on them.

Perhaps TaskGroup can be special-cased to ignore this error, or maybe special-case Task so the rule only applies when it is returned from asyncio.create_task()?

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugmypy got something wrongfalse-positivemypy gave an error on correct codetopic-asyncasync, await, asyncio

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions