-
Notifications
You must be signed in to change notification settings - Fork 2k
Invalid python code in the documentation for ASYNC100 rule #12921
Copy link
Copy link
Closed
Labels
documentationImprovements or additions to documentationImprovements or additions to documentation
Description
Examples for the rule cancel-scope-no-checkpoint (ASYNC100) are not valid python code
ruff/crates/ruff_linter/src/rules/flake8_async/rules/cancel_scope_no_checkpoint.rs
Lines 29 to 35 in d8debb7
| /// Use instead: | |
| /// ```python | |
| /// async def func(): | |
| /// with asyncio.timeout(2): | |
| /// do_something() | |
| /// await awaitable() | |
| /// ``` |
The code
import asyncio
async def func():
with asyncio.timeout(2):
do_something()
await awaitable()
asyncio.run(func())will throw a TypeError
TypeError: 'Timeout' object does not support the context manager protocol
because asyncio.timeout is an asynchronous context manager.
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
documentationImprovements or additions to documentationImprovements or additions to documentation