Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
jamesbraza opened this issue Jul 17, 2024 · 0 comments · Fixed by #12605
Closed

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

jamesbraza opened this issue Jul 17, 2024 · 0 comments · Fixed by #12605
Assignees
Labels
bug Something isn't working

Comments

@jamesbraza
Copy link
Contributor

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__

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants