-
Notifications
You must be signed in to change notification settings - Fork 2k
False positive ASYNC109 when timeout goes to asyncio.timeout #12353
Copy link
Copy link
Closed
Labels
documentationImprovements or additions to documentationImprovements or additions to documentationruleImplementing or modifying a lint ruleImplementing or modifying a lint rule
Description
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?
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
documentationImprovements or additions to documentationImprovements or additions to documentationruleImplementing or modifying a lint ruleImplementing or modifying a lint rule