mirror of
https://github.com/astral-sh/ruff
synced 2026-01-07 14:44:17 -05:00
[red-knot] Type narrow in else clause (#13918)
## Summary Add support for type narrowing in elif and else scopes as part of #13694. ## Test Plan - mdtest - builder unit test for union negation. --------- Co-authored-by: Carl Meyer <carl@astral.sh>
This commit is contained in:
@@ -3071,6 +3071,22 @@ impl CmpOp {
|
||||
CmpOp::NotIn => "not in",
|
||||
}
|
||||
}
|
||||
|
||||
#[must_use]
|
||||
pub const fn negate(&self) -> Self {
|
||||
match self {
|
||||
CmpOp::Eq => CmpOp::NotEq,
|
||||
CmpOp::NotEq => CmpOp::Eq,
|
||||
CmpOp::Lt => CmpOp::GtE,
|
||||
CmpOp::LtE => CmpOp::Gt,
|
||||
CmpOp::Gt => CmpOp::LtE,
|
||||
CmpOp::GtE => CmpOp::Lt,
|
||||
CmpOp::Is => CmpOp::IsNot,
|
||||
CmpOp::IsNot => CmpOp::Is,
|
||||
CmpOp::In => CmpOp::NotIn,
|
||||
CmpOp::NotIn => CmpOp::In,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl fmt::Display for CmpOp {
|
||||
|
||||
Reference in New Issue
Block a user