Respect indent when measuring with MeasureMode::AllLines (#6120)

This commit is contained in:
Micha Reiser 2023-07-27 13:34:36 +02:00 committed by Charlie Marsh
parent 9574ff3dc7
commit 6bf6646c5d
5 changed files with 109 additions and 51 deletions

View file

@ -75,7 +75,7 @@ impl FormatNodeRule<ExprAttribute> for FormatExprAttribute {
impl NeedsParentheses for ExprAttribute {
fn needs_parentheses(
&self,
parent: AnyNodeRef,
_parent: AnyNodeRef,
context: &PyFormatContext,
) -> OptionalParentheses {
// Checks if there are any own line comments in an attribute chain (a.b.c).
@ -88,7 +88,7 @@ impl NeedsParentheses for ExprAttribute {
{
OptionalParentheses::Always
} else {
self.value.needs_parentheses(parent, context)
self.value.needs_parentheses(self.into(), context)
}
}
}

View file

@ -119,10 +119,10 @@ impl FormatNodeRule<ExprCall> for FormatExprCall {
impl NeedsParentheses for ExprCall {
fn needs_parentheses(
&self,
parent: AnyNodeRef,
_parent: AnyNodeRef,
context: &PyFormatContext,
) -> OptionalParentheses {
self.func.needs_parentheses(parent, context)
self.func.needs_parentheses(self.into(), context)
}
}