mirror of
https://github.com/astral-sh/ruff
synced 2026-01-22 05:51:03 -05:00
Fix B015 false positive on comparison deep inside expression statement (#616)
This commit is contained in:
@@ -1,14 +1,14 @@
|
||||
use rustpython_ast::{Expr, Stmt, StmtKind};
|
||||
use rustpython_ast::{Expr, ExprKind};
|
||||
|
||||
use crate::ast::types::{CheckLocator, Range};
|
||||
use crate::check_ast::Checker;
|
||||
use crate::checks::{Check, CheckKind};
|
||||
|
||||
pub fn useless_comparison(checker: &mut Checker, expr: &Expr, parent: &Stmt) {
|
||||
if let StmtKind::Expr { .. } = &parent.node {
|
||||
pub fn useless_comparison(checker: &mut Checker, expr: &Expr) {
|
||||
if let ExprKind::Compare { left, .. } = &expr.node {
|
||||
checker.add_check(Check::new(
|
||||
CheckKind::UselessComparison,
|
||||
checker.locate_check(Range::from_located(expr)),
|
||||
checker.locate_check(Range::from_located(left)),
|
||||
));
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user