Split tuples in return positions by comma first (#8280)

This commit is contained in:
Micha Reiser 2023-10-30 09:25:44 +09:00 committed by GitHub
parent 3ccca332bd
commit c7aa816f17
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 117 additions and 2 deletions

View file

@ -172,10 +172,13 @@ impl FormatNodeRule<ExprTuple> for FormatExprTuple {
.finish()
}
TupleParentheses::Preserve => group(&ExprSequence::new(item)).fmt(f),
TupleParentheses::NeverPreserve | TupleParentheses::OptionalParentheses => {
TupleParentheses::NeverPreserve => {
optional_parentheses(&ExprSequence::new(item)).fmt(f)
}
TupleParentheses::Default => {
TupleParentheses::OptionalParentheses if item.elts.len() == 2 => {
optional_parentheses(&ExprSequence::new(item)).fmt(f)
}
TupleParentheses::Default | TupleParentheses::OptionalParentheses => {
parenthesize_if_expands(&ExprSequence::new(item)).fmt(f)
}
},