Skip to content

Commit

Permalink
Simplify parenthesized formatting (#6419)
Browse files Browse the repository at this point in the history
  • Loading branch information
MichaReiser authored Aug 8, 2023
1 parent 289d1e8 commit 2bd3453
Showing 1 changed file with 7 additions and 16 deletions.
23 changes: 7 additions & 16 deletions crates/ruff_python_formatter/src/expression/parentheses.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down

0 comments on commit 2bd3453

Please sign in to comment.