Skip to content

Commit 2bd3453

Browse files
authored
Simplify parenthesized formatting (#6419)
1 parent 289d1e8 commit 2bd3453

File tree

1 file changed

+7
-16
lines changed

1 file changed

+7
-16
lines changed

crates/ruff_python_formatter/src/expression/parentheses.rs

Lines changed: 7 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -144,22 +144,13 @@ impl<'content, 'ast> FormatParenthesized<'content, 'ast> {
144144
impl<'ast> Format<PyFormatContext<'ast>> for FormatParenthesized<'_, 'ast> {
145145
fn fmt(&self, f: &mut Formatter<PyFormatContext<'ast>>) -> FormatResult<()> {
146146
let inner = format_with(|f| {
147-
if self.comments.is_empty() {
148-
group(&format_args![
149-
text(self.left),
150-
&soft_block_indent(&Arguments::from(&self.content)),
151-
text(self.right)
152-
])
153-
.fmt(f)
154-
} else {
155-
group(&format_args![
156-
text(self.left),
157-
&dangling_open_parenthesis_comments(self.comments),
158-
&soft_block_indent(&Arguments::from(&self.content)),
159-
text(self.right)
160-
])
161-
.fmt(f)
162-
}
147+
group(&format_args![
148+
text(self.left),
149+
&dangling_open_parenthesis_comments(self.comments),
150+
&soft_block_indent(&Arguments::from(&self.content)),
151+
text(self.right)
152+
])
153+
.fmt(f)
163154
});
164155

165156
let current_level = f.context().node_level();

0 commit comments

Comments
 (0)