diff --git a/crates/ruff_linter/resources/test/fixtures/ruff/RUF029.py b/crates/ruff_linter/resources/test/fixtures/ruff/RUF029.py index f2c42b3d9cdb4..3c214806d6862 100644 --- a/crates/ruff_linter/resources/test/fixtures/ruff/RUF029.py +++ b/crates/ruff_linter/resources/test/fixtures/ruff/RUF029.py @@ -69,3 +69,7 @@ async def foo(self): def foo(): async def fail_4c(): # RUF029: the /inner/ function does not await pass + + +async def test(): + return [check async for check in async_func()] diff --git a/crates/ruff_linter/src/rules/ruff/rules/unused_async.rs b/crates/ruff_linter/src/rules/ruff/rules/unused_async.rs index e6180c945a906..29a2c851d090b 100644 --- a/crates/ruff_linter/src/rules/ruff/rules/unused_async.rs +++ b/crates/ruff_linter/src/rules/ruff/rules/unused_async.rs @@ -84,6 +84,11 @@ impl<'a> preorder::PreorderVisitor<'a> for AsyncExprVisitor { _ => preorder::walk_stmt(self, stmt), } } + fn visit_comprehension(&mut self, comprehension: &'a ast::Comprehension) { + if comprehension.is_async { + self.found_await_or_async = true; + } + } } /// Very nearly `crate::node::StmtFunctionDef.visit_preorder`, except it is specialized and,