Skip to content

Commit

Permalink
[ruff] fix async comprehension false positive (RUF029) (#11070)
Browse files Browse the repository at this point in the history
## Summary

- Fix #11043 

## Test Plan

Added the false positive code in the test fixture.
  • Loading branch information
JonathanPlasse committed Apr 21, 2024
1 parent d544199 commit a689388
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 0 deletions.
4 changes: 4 additions & 0 deletions crates/ruff_linter/resources/test/fixtures/ruff/RUF029.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()]
5 changes: 5 additions & 0 deletions crates/ruff_linter/src/rules/ruff/rules/unused_async.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down

0 comments on commit a689388

Please sign in to comment.