Skip to content

False positive ASYNC100 when pairing asyncio.timeout with asyncio.TaskGroup #12354

@jamesbraza

Description

@jamesbraza

The below Python 3.12 code with ruff==0.5.2:

import asyncio

async def foo() -> None:
    async with asyncio.timeout(2.0), asyncio.TaskGroup() as tg:
        tg.create_task(asyncio.sleep(1))

Will throw an ASYNC100 error on the fourth line:

a.py:4:5: ASYNC100 A `with asyncio.timeout(...):` context does not contain any `await` statements. This makes it pointless, as the timeout can only be triggered by a checkpoint.

I think this is a false positive, as the inner asyncio.TaskGroup has an implicit await during its __exit__

Metadata

Metadata

Assignees

Labels

bugSomething isn't working

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions