Simplify parenthesized formatting (#6419)

This commit is contained in:
Micha Reiser 2023-08-08 10:50:57 +02:00 committed by GitHub
parent 289d1e85bf
commit 2bd345358f
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -144,22 +144,13 @@ impl<'content, 'ast> FormatParenthesized<'content, 'ast> {
impl<'ast> Format<PyFormatContext<'ast>> for FormatParenthesized<'_, 'ast> {
fn fmt(&self, f: &mut Formatter<PyFormatContext<'ast>>) -> FormatResult<()> {
let inner = format_with(|f| {
if self.comments.is_empty() {
group(&format_args![
text(self.left),
&soft_block_indent(&Arguments::from(&self.content)),
text(self.right)
])
.fmt(f)
} else {
group(&format_args![
text(self.left),
&dangling_open_parenthesis_comments(self.comments),
&soft_block_indent(&Arguments::from(&self.content)),
text(self.right)
])
.fmt(f)
}
group(&format_args![
text(self.left),
&dangling_open_parenthesis_comments(self.comments),
&soft_block_indent(&Arguments::from(&self.content)),
text(self.right)
])
.fmt(f)
});
let current_level = f.context().node_level();