Examples for the rule cancel-scope-no-checkpoint (ASYNC100) are not valid python code
|
/// 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.
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
The code
will throw a TypeError
TypeError: 'Timeout' object does not support the context manager protocolbecause
asyncio.timeoutis an asynchronous context manager.