mirror of
https://github.com/astral-sh/ruff.git
synced 2025-08-10 13:48:18 +00:00
Avoid unstable formatting in ellipsis-only body with trailing comment (#8984)
## Summary We should avoid inlining the ellipsis in: ```python def h(): ... # bye ``` Just as we omit the ellipsis in: ```python def h(): # bye ... ``` Closes https://github.com/astral-sh/ruff/issues/8905.
This commit is contained in:
parent
bfae1f1412
commit
6fe8f8a272
3 changed files with 18 additions and 3 deletions
|
@ -511,7 +511,9 @@ pub(crate) fn contains_only_an_ellipsis(body: &[Stmt], comments: &Comments) -> b
|
|||
let [node] = body else {
|
||||
return false;
|
||||
};
|
||||
value.is_ellipsis_literal_expr() && !comments.has_leading(node)
|
||||
value.is_ellipsis_literal_expr()
|
||||
&& !comments.has_leading(node)
|
||||
&& !comments.has_trailing_own_line(node)
|
||||
}
|
||||
_ => false,
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue