mirror of
https://github.com/astral-sh/ruff.git
synced 2025-08-19 01:51:30 +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> {
|
impl<'ast> Format<PyFormatContext<'ast>> for FormatParenthesized<'_, 'ast> {
|
||||||
fn fmt(&self, f: &mut Formatter<PyFormatContext<'ast>>) -> FormatResult<()> {
|
fn fmt(&self, f: &mut Formatter<PyFormatContext<'ast>>) -> FormatResult<()> {
|
||||||
let inner = format_with(|f| {
|
let inner = format_with(|f| {
|
||||||
if self.comments.is_empty() {
|
group(&format_args![
|
||||||
group(&format_args![
|
text(self.left),
|
||||||
text(self.left),
|
&dangling_open_parenthesis_comments(self.comments),
|
||||||
&soft_block_indent(&Arguments::from(&self.content)),
|
&soft_block_indent(&Arguments::from(&self.content)),
|
||||||
text(self.right)
|
text(self.right)
|
||||||
])
|
])
|
||||||
.fmt(f)
|
.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)
|
|
||||||
}
|
|
||||||
});
|
});
|
||||||
|
|
||||||
let current_level = f.context().node_level();
|
let current_level = f.context().node_level();
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue