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

@ -91,7 +91,7 @@ impl FormatNodeRule<ExprBinOp> for FormatExprBinOp {
)?;
// Format the operator on its own line if the right side has any leading comments.
if comments.has_leading_comments(right.as_ref().into()) {
if comments.has_leading_comments(right.as_ref()) {
write!(f, [hard_line_break()])?;
} else if needs_space {
write!(f, [space()])?;

View file

@ -35,7 +35,7 @@ impl Format<PyFormatContext<'_>> for KeyValuePair<'_> {
)
} else {
let comments = f.context().comments().clone();
let leading_value_comments = comments.leading_comments(self.value.into());
let leading_value_comments = comments.leading_comments(self.value);
write!(
f,
[

View file

@ -19,7 +19,7 @@ impl FormatNodeRule<ExprList> for FormatExprList {
} = item;
let comments = f.context().comments().clone();
let dangling = comments.dangling_comments(item.into());
let dangling = comments.dangling_comments(item);
// The empty list is special because there can be dangling comments, and they can be in two
// positions: