mirror of https://github.com/astral-sh/ruff
Fix false positive for `IfTuple` (#96)
This commit is contained in:
parent
97cc30768d
commit
e2f46537fd
|
|
@ -6,3 +6,5 @@ for _ in range(5):
|
||||||
pass
|
pass
|
||||||
elif (3, 4):
|
elif (3, 4):
|
||||||
pass
|
pass
|
||||||
|
elif ():
|
||||||
|
pass
|
||||||
|
|
|
||||||
|
|
@ -241,7 +241,8 @@ impl Visitor for Checker<'_> {
|
||||||
}
|
}
|
||||||
StmtKind::If { test, .. } => {
|
StmtKind::If { test, .. } => {
|
||||||
if self.settings.select.contains(CheckKind::IfTuple.code()) {
|
if self.settings.select.contains(CheckKind::IfTuple.code()) {
|
||||||
if let ExprKind::Tuple { .. } = test.node {
|
if let ExprKind::Tuple { elts, .. } = &test.node {
|
||||||
|
if !elts.is_empty() {
|
||||||
self.checks.push(Check {
|
self.checks.push(Check {
|
||||||
kind: CheckKind::IfTuple,
|
kind: CheckKind::IfTuple,
|
||||||
location: stmt.location,
|
location: stmt.location,
|
||||||
|
|
@ -249,6 +250,7 @@ impl Visitor for Checker<'_> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
StmtKind::Raise { exc, .. } => {
|
StmtKind::Raise { exc, .. } => {
|
||||||
if self
|
if self
|
||||||
.settings
|
.settings
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue