Skip to content

False positive ASYNC109 when timeout goes to asyncio.timeout #12353

@jamesbraza

Description

@jamesbraza

The below Python 3.12 code with ruff==0.5.2:

import asyncio

async def foo(timeout: float | None = 30.0) -> None:
    async with asyncio.timeout(timeout):
        await asyncio.sleep(1.0)

Will throw an ASYNC109 error on the third line:

a.py:3:15: ASYNC109 Async function definition with a `timeout` parameter

I think this is a false positive, as later on the timeout is directly used in an asyncio.timeout.

Is there some way Ruff can check for how the timeout is used before throwing ASYNC109?

Metadata

Metadata

Assignees

No one assigned

    Labels

    documentationImprovements or additions to documentationruleImplementing or modifying a lint rule

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions