mirror of
https://github.com/astral-sh/ruff.git
synced 2025-07-23 21:15:19 +00:00
Simplify parenthesized
formatting (#6419)
This commit is contained in:
parent
289d1e85bf
commit
2bd345358f
1 changed files with 7 additions and 16 deletions
|
@ -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();
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue