mirror of
https://github.com/astral-sh/ruff.git
synced 2025-07-23 04:55:21 +00:00
Remove some unnecessary ampersands in the formatter (#6667)
This commit is contained in:
parent
8e18f8018f
commit
3ceb6fbeb0
9 changed files with 13 additions and 13 deletions
|
@ -1698,7 +1698,7 @@ two lines`,
|
||||||
text("]")
|
text("]")
|
||||||
]),
|
]),
|
||||||
text(";"),
|
text(";"),
|
||||||
&line_suffix(&format_args![space(), text("// trailing")])
|
line_suffix(&format_args![space(), text("// trailing")])
|
||||||
]);
|
]);
|
||||||
|
|
||||||
assert_eq!(printed.as_code(), "[1, 2, 3]; // trailing");
|
assert_eq!(printed.as_code(), "[1, 2, 3]; // trailing");
|
||||||
|
|
|
@ -41,7 +41,7 @@ impl FormatNodeRule<ExprDictComp> for FormatExprDictComp {
|
||||||
space(),
|
space(),
|
||||||
value.format(),
|
value.format(),
|
||||||
soft_line_break_or_space(),
|
soft_line_break_or_space(),
|
||||||
&joined
|
joined
|
||||||
)),
|
)),
|
||||||
"}"
|
"}"
|
||||||
)
|
)
|
||||||
|
|
|
@ -68,7 +68,7 @@ impl FormatNodeRule<ExprGeneratorExp> for FormatExprGeneratorExp {
|
||||||
&group(&format_args!(
|
&group(&format_args!(
|
||||||
group(&elt.format()),
|
group(&elt.format()),
|
||||||
soft_line_break_or_space(),
|
soft_line_break_or_space(),
|
||||||
&joined
|
joined
|
||||||
)),
|
)),
|
||||||
")"
|
")"
|
||||||
)
|
)
|
||||||
|
|
|
@ -36,7 +36,7 @@ impl FormatNodeRule<ExprListComp> for FormatExprListComp {
|
||||||
&group(&format_args![
|
&group(&format_args![
|
||||||
group(&elt.format()),
|
group(&elt.format()),
|
||||||
soft_line_break_or_space(),
|
soft_line_break_or_space(),
|
||||||
&joined
|
joined
|
||||||
]),
|
]),
|
||||||
"]"
|
"]"
|
||||||
)
|
)
|
||||||
|
|
|
@ -36,7 +36,7 @@ impl FormatNodeRule<ExprSetComp> for FormatExprSetComp {
|
||||||
&group(&format_args!(
|
&group(&format_args!(
|
||||||
group(&elt.format()),
|
group(&elt.format()),
|
||||||
soft_line_break_or_space(),
|
soft_line_break_or_space(),
|
||||||
&joined
|
joined
|
||||||
)),
|
)),
|
||||||
"}"
|
"}"
|
||||||
)
|
)
|
||||||
|
|
|
@ -153,8 +153,8 @@ impl<'ast> Format<PyFormatContext<'ast>> for FormatParenthesized<'_, 'ast> {
|
||||||
let inner = format_with(|f| {
|
let inner = format_with(|f| {
|
||||||
group(&format_args![
|
group(&format_args![
|
||||||
text(self.left),
|
text(self.left),
|
||||||
&dangling_open_parenthesis_comments(self.comments),
|
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)
|
||||||
|
|
|
@ -27,9 +27,9 @@ impl FormatNodeRule<StmtDelete> for FormatStmtDelete {
|
||||||
// del (
|
// del (
|
||||||
// # Dangling comment
|
// # Dangling comment
|
||||||
// )
|
// )
|
||||||
&text("("),
|
text("("),
|
||||||
block_indent(&dangling_node_comments(item)),
|
block_indent(&dangling_node_comments(item)),
|
||||||
&text(")"),
|
text(")"),
|
||||||
]
|
]
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
|
@ -42,10 +42,10 @@ impl FormatNodeRule<StmtGlobal> for FormatStmtGlobal {
|
||||||
[
|
[
|
||||||
text("global"),
|
text("global"),
|
||||||
space(),
|
space(),
|
||||||
&group(&format_args!(
|
group(&format_args!(
|
||||||
if_group_breaks(&text("\\")),
|
if_group_breaks(&text("\\")),
|
||||||
soft_line_break(),
|
soft_line_break(),
|
||||||
&soft_block_indent(&joined)
|
soft_block_indent(&joined)
|
||||||
))
|
))
|
||||||
]
|
]
|
||||||
)
|
)
|
||||||
|
|
|
@ -42,10 +42,10 @@ impl FormatNodeRule<StmtNonlocal> for FormatStmtNonlocal {
|
||||||
[
|
[
|
||||||
text("nonlocal"),
|
text("nonlocal"),
|
||||||
space(),
|
space(),
|
||||||
&group(&format_args!(
|
group(&format_args!(
|
||||||
if_group_breaks(&text("\\")),
|
if_group_breaks(&text("\\")),
|
||||||
soft_line_break(),
|
soft_line_break(),
|
||||||
&soft_block_indent(&joined)
|
soft_block_indent(&joined)
|
||||||
))
|
))
|
||||||
]
|
]
|
||||||
)
|
)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue