mirror of
https://github.com/astral-sh/ruff.git
synced 2025-07-24 05:25:17 +00:00
magic trailing comma for ExprList (#5365)
This commit is contained in:
parent
190bed124f
commit
50a7769d69
11 changed files with 163 additions and 186 deletions
|
@ -52,23 +52,7 @@ impl FormatNodeRule<ExprList> for FormatExprList {
|
|||
"A non-empty expression list has dangling comments"
|
||||
);
|
||||
|
||||
let items = format_with(|f| {
|
||||
let mut iter = elts.iter();
|
||||
|
||||
if let Some(first) = iter.next() {
|
||||
write!(f, [first.format()])?;
|
||||
}
|
||||
|
||||
for item in iter {
|
||||
write!(f, [text(","), soft_line_break_or_space(), item.format()])?;
|
||||
}
|
||||
|
||||
if !elts.is_empty() {
|
||||
write!(f, [if_group_breaks(&text(","))])?;
|
||||
}
|
||||
|
||||
Ok(())
|
||||
});
|
||||
let items = format_with(|f| f.join_comma_separated().nodes(elts.iter()).finish());
|
||||
|
||||
write!(
|
||||
f,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue