From 6f646d261a0d982745b04d0d095b4f5217152776 Mon Sep 17 00:00:00 2001 From: Charlie Marsh Date: Wed, 14 Aug 2024 20:57:53 -0400 Subject: [PATCH] Minor tweaks --- .../resources/test/fixtures/flake8_async/ASYNC100.py | 7 +++++-- ...__rules__flake8_async__tests__ASYNC100_ASYNC100.py.snap | 2 -- 2 files changed, 5 insertions(+), 4 deletions(-) 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 cdd271267be5d4..8434073d22dac8 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/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 b3e3b067d5ff22..0eca205a5b4680 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 |