Fix false positive for IfTuple

This commit is contained in:
harupy 2022-09-04 10:28:41 +09:00
parent 97cc30768d
commit ad15814811
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.len() > 0 {
self.checks.push(Check {
kind: CheckKind::IfTuple,
location: stmt.location,
});
}
}
}
}