Skip to content

Commit

Permalink
remove repeated logic
Browse files Browse the repository at this point in the history
  • Loading branch information
diceroll123 committed Oct 17, 2023
1 parent 8aeb3a1 commit 0b42ef0
Showing 1 changed file with 4 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,10 @@ pub(crate) fn unnecessary_literal_union<'a>(checker: &mut Checker, expr: &'a Exp
if checker.semantic().match_typing_expr(value, "Literal") {
total_literals += 1;

if literal_subscript.is_none() {
literal_subscript = Some(*value.clone());
}

// flatten already-unioned literals to later union again
if let Expr::Tuple(ast::ExprTuple {
elts,
Expand All @@ -120,15 +124,9 @@ pub(crate) fn unnecessary_literal_union<'a>(checker: &mut Checker, expr: &'a Exp
}) = slice.as_ref()
{
for expr in elts {
if literal_subscript.is_none() {
literal_subscript = Some(*value.clone());
}
literal_exprs.push(expr);
}
} else {
if literal_subscript.is_none() {
literal_subscript = Some(*value.clone());
}
literal_exprs.push(slice.as_ref());
}
}
Expand Down

0 comments on commit 0b42ef0

Please sign in to comment.