Handle right parens in join comma builder (#5711)

This commit is contained in:
Micha Reiser 2023-07-12 18:21:28 +02:00 committed by GitHub
parent f0aa6bd4d3
commit 653429bef9
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
11 changed files with 159 additions and 136 deletions

View file

@ -4,7 +4,7 @@ use crate::expression::parentheses::Parenthesize;
use crate::{AsFormat, FormatNodeRule, PyFormatter};
use ruff_formatter::prelude::{block_indent, format_with, space, text};
use ruff_formatter::{write, Buffer, Format, FormatResult};
use rustpython_parser::ast::StmtDelete;
use rustpython_parser::ast::{Ranged, StmtDelete};
#[derive(Default)]
pub struct FormatStmtDelete;
@ -35,7 +35,11 @@ impl FormatNodeRule<StmtDelete> for FormatStmtDelete {
write!(f, [single.format().with_options(Parenthesize::IfBreaks)])
}
targets => {
let item = format_with(|f| f.join_comma_separated().nodes(targets.iter()).finish());
let item = format_with(|f| {
f.join_comma_separated(item.end())
.nodes(targets.iter())
.finish()
});
parenthesize_if_expands(&item).fmt(f)
}
}