Avoid triggering SIM117 for async with statements

This commit is contained in:
Charlie Marsh 2023-01-15 21:33:18 -05:00
parent d71a615b18
commit 396be5edea
2 changed files with 14 additions and 2 deletions

View file

@ -16,3 +16,15 @@ with A() as a:
with B() as b:
print("hello")
a()
async with A() as a:
with B() as b:
print("hello")
with A() as a:
async with B() as b:
print("hello")
async with A() as a:
async with B() as b:
print("hello")

View file

@ -1279,7 +1279,7 @@ where
}
}
}
StmtKind::With { items, body, .. } | StmtKind::AsyncWith { items, body, .. } => {
StmtKind::With { items, body, .. } => {
if self.settings.enabled.contains(&RuleCode::B017) {
flake8_bugbear::rules::assert_raises_exception(self, stmt, items);
}
@ -1291,7 +1291,7 @@ where
self,
stmt,
body,
self.current_stmt_parent().map(|parent| parent.0),
self.current_stmt_parent().map(Into::into),
);
}
}