diff --git a/crates/ruff_linter/resources/test/fixtures/flake8_async/ASYNC100.py b/crates/ruff_linter/resources/test/fixtures/flake8_async/ASYNC100.py index cdd271267be5d..8434073d22dac 100644 --- a/crates/ruff_linter/resources/test/fixtures/flake8_async/ASYNC100.py +++ b/crates/ruff_linter/resources/test/fixtures/flake8_async/ASYNC100.py @@ -89,12 +89,14 @@ async def func(): async def func(): async with asyncio.timeout(delay=0.2), asyncio.timeout(delay=0.2): ... - + + # Don't trigger for blocks with a yield statement async def foo(): with trio.fail_after(1): yield + async def foo(): # even if only one branch contains a yield, we skip the lint with trio.fail_after(1): if something: @@ -102,10 +104,11 @@ async def foo(): # even if only one branch contains a yield, we skip the lint else: yield + # https://github.com/astral-sh/ruff/issues/12873 @asynccontextmanager async def good_code(): with anyio.fail_after(10): # There's no await keyword here, but we presume that there # will be in the caller we yield to, so this is safe. - yield \ No newline at end of file + yield diff --git a/crates/ruff_linter/src/rules/flake8_async/rules/cancel_scope_no_checkpoint.rs b/crates/ruff_linter/src/rules/flake8_async/rules/cancel_scope_no_checkpoint.rs index 132f31fcab5a2..6b0b55b014654 100644 --- a/crates/ruff_linter/src/rules/flake8_async/rules/cancel_scope_no_checkpoint.rs +++ b/crates/ruff_linter/src/rules/flake8_async/rules/cancel_scope_no_checkpoint.rs @@ -85,8 +85,8 @@ pub(crate) fn cancel_scope_no_checkpoint( // Treat yields as checkpoints, since checkpoints can happen // in the caller yielded to. - // https://flake8-async.readthedocs.io/en/latest/rules.html#async100 - // https://github.com/astral-sh/ruff/issues/12873 + // See: https://flake8-async.readthedocs.io/en/latest/rules.html#async100 + // See: https://github.com/astral-sh/ruff/issues/12873 if any_over_body(&with_stmt.body, &Expr::is_yield_expr) { return; } diff --git a/crates/ruff_linter/src/rules/flake8_async/snapshots/ruff_linter__rules__flake8_async__tests__ASYNC100_ASYNC100.py.snap b/crates/ruff_linter/src/rules/flake8_async/snapshots/ruff_linter__rules__flake8_async__tests__ASYNC100_ASYNC100.py.snap index b3e3b067d5ff2..0eca205a5b468 100644 --- a/crates/ruff_linter/src/rules/flake8_async/snapshots/ruff_linter__rules__flake8_async__tests__ASYNC100_ASYNC100.py.snap +++ b/crates/ruff_linter/src/rules/flake8_async/snapshots/ruff_linter__rules__flake8_async__tests__ASYNC100_ASYNC100.py.snap @@ -98,6 +98,4 @@ ASYNC100.py:90:5: ASYNC100 A `with asyncio.timeout(...):` context does not conta | _____^ 91 | | ... | |___________^ ASYNC100 -92 | -93 | # Don't trigger for blocks with a yield statement |