mirror of https://github.com/astral-sh/ruff
share common code
This commit is contained in:
parent
5fee7534f7
commit
d1b79f5400
|
|
@ -409,25 +409,15 @@ impl Format<PyFormatContext<'_>> for FormatBody<'_> {
|
||||||
if is_expression_parenthesized((*body).into(), comments.ranges(), f.context().source())
|
if is_expression_parenthesized((*body).into(), comments.ranges(), f.context().source())
|
||||||
&& comments.has_leading(*body)
|
&& comments.has_leading(*body)
|
||||||
{
|
{
|
||||||
|
trailing_comments(dangling).fmt(f)?;
|
||||||
|
|
||||||
if leading_body_comments.is_empty() {
|
if leading_body_comments.is_empty() {
|
||||||
write!(
|
space().fmt(f)?;
|
||||||
f,
|
|
||||||
[
|
|
||||||
space(),
|
|
||||||
trailing_comments(dangling),
|
|
||||||
body.format().with_options(Parentheses::Always),
|
|
||||||
]
|
|
||||||
)
|
|
||||||
} else {
|
} else {
|
||||||
write!(
|
hard_line_break().fmt(f)?;
|
||||||
f,
|
|
||||||
[
|
|
||||||
trailing_comments(dangling),
|
|
||||||
hard_line_break(),
|
|
||||||
body.format().with_options(Parentheses::Always)
|
|
||||||
]
|
|
||||||
)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
body.format().with_options(Parentheses::Always).fmt(f)
|
||||||
} else {
|
} else {
|
||||||
write!(
|
write!(
|
||||||
f,
|
f,
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue