mirror of https://github.com/astral-sh/ruff
[red-knot] simplify != narrowing (#17610)
## Summary Follow-up from review comment in https://github.com/astral-sh/ruff/pull/17567#discussion_r2058649527 ## Test Plan Existing tests.
This commit is contained in:
parent
e71f3ed2c5
commit
25c3be51d2
|
|
@ -512,19 +512,10 @@ impl<'db> NarrowingConstraintsBuilder<'db> {
|
||||||
None
|
None
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
(_, Type::BooleanLiteral(b)) => {
|
(_, Type::BooleanLiteral(b)) => Some(
|
||||||
if b {
|
UnionType::from_elements(self.db, [rhs_ty, Type::IntLiteral(i64::from(b))])
|
||||||
Some(
|
.negate(self.db),
|
||||||
UnionType::from_elements(self.db, [rhs_ty, Type::IntLiteral(1)])
|
),
|
||||||
.negate(self.db),
|
|
||||||
)
|
|
||||||
} else {
|
|
||||||
Some(
|
|
||||||
UnionType::from_elements(self.db, [rhs_ty, Type::IntLiteral(0)])
|
|
||||||
.negate(self.db),
|
|
||||||
)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
_ if rhs_ty.is_single_valued(self.db) => Some(rhs_ty.negate(self.db)),
|
_ if rhs_ty.is_single_valued(self.db) => Some(rhs_ty.negate(self.db)),
|
||||||
_ => None,
|
_ => None,
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue