Accept any Into<AnyNodeRef> as Comments arguments (#5205)

This commit is contained in:
Micha Reiser 2023-06-20 18:49:21 +02:00 committed by GitHub
parent 6f7d3cc798
commit b369288833
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
9 changed files with 73 additions and 41 deletions

View file

@ -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),