mirror of
https://github.com/astral-sh/ruff.git
synced 2025-08-19 01:51:30 +00:00
Accept any Into<AnyNodeRef>
as Comments
arguments (#5205)
This commit is contained in:
parent
6f7d3cc798
commit
b369288833
9 changed files with 73 additions and 41 deletions
|
@ -96,13 +96,12 @@ impl FormatRule<Suite, PyFormatContext<'_>> for FormatSuite {
|
|||
// the leading comment. This is why the suite handling counts the lines before the
|
||||
// start of the next statement or before the first leading comments for compound statements.
|
||||
let separator = format_with(|f| {
|
||||
let start = if let Some(first_leading) =
|
||||
comments.leading_comments(statement.into()).first()
|
||||
{
|
||||
first_leading.slice().start()
|
||||
} else {
|
||||
statement.start()
|
||||
};
|
||||
let start =
|
||||
if let Some(first_leading) = comments.leading_comments(statement).first() {
|
||||
first_leading.slice().start()
|
||||
} else {
|
||||
statement.start()
|
||||
};
|
||||
|
||||
match lines_before(start, source) {
|
||||
0 | 1 => hard_line_break().fmt(f),
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue