mirror of
https://github.com/astral-sh/ruff.git
synced 2025-09-30 22:01:47 +00:00
[ruff] fix async comprehension false positive (RUF029) (#11070)
## Summary - Fix #11043 ## Test Plan Added the false positive code in the test fixture.
This commit is contained in:
parent
d544199272
commit
a68938897d
2 changed files with 9 additions and 0 deletions
|
@ -69,3 +69,7 @@ async def fail_4b(): # RUF029: the /outer/ function does not await
|
|||
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()]
|
||||
|
|
|
@ -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,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue