Respect async with in timeout-without-await (#9859)

Closes https://github.com/astral-sh/ruff/issues/9855.
This commit is contained in:
Charlie Marsh
2024-02-06 09:04:24 -08:00
committed by GitHub
parent 75553ab1c0
commit daae28efc7
3 changed files with 24 additions and 13 deletions

View File

@@ -1021,6 +1021,12 @@ impl Visitor<'_> for AwaitVisitor {
fn visit_stmt(&mut self, stmt: &Stmt) {
match stmt {
Stmt::FunctionDef(_) | Stmt::ClassDef(_) => (),
Stmt::With(ast::StmtWith { is_async: true, .. }) => {
self.seen_await = true;
}
Stmt::For(ast::StmtFor { is_async: true, .. }) => {
self.seen_await = true;
}
_ => crate::visitor::walk_stmt(self, stmt),
}
}