Fix false positive for `IfTuple` (#96)

This commit is contained in:
Harutaka Kawamura 2022-09-04 11:56:55 +09:00 committed by GitHub
parent 97cc30768d
commit e2f46537fd
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 9 additions and 5 deletions

View File

@ -6,3 +6,5 @@ for _ in range(5):
pass
elif (3, 4):
pass
elif ():
pass

View File

@ -241,11 +241,13 @@ impl Visitor for Checker<'_> {
}
StmtKind::If { test, .. } => {
if self.settings.select.contains(CheckKind::IfTuple.code()) {
if let ExprKind::Tuple { .. } = test.node {
self.checks.push(Check {
kind: CheckKind::IfTuple,
location: stmt.location,
});
if let ExprKind::Tuple { elts, .. } = &test.node {
if !elts.is_empty() {
self.checks.push(Check {
kind: CheckKind::IfTuple,
location: stmt.location,
});
}
}
}
}