This commit is contained in:
Micha Reiser
2023-09-16 16:50:36 +02:00
committed by GitHub
parent 916dd5b7fa
commit c907317199
3 changed files with 23 additions and 10 deletions

View File

@@ -38,7 +38,11 @@ impl FormatNodeRule<ExprCall> for FormatExprCall {
let fmt_func = format_with(|f: &mut PyFormatter| {
// Format the function expression.
if is_expression_parenthesized(func.into(), f.context().source()) {
if is_expression_parenthesized(
func.into(),
f.context().comments().ranges(),
f.context().source(),
) {
func.format().with_options(Parentheses::Always).fmt(f)
} else {
match func.as_ref() {

View File

@@ -43,7 +43,11 @@ impl FormatNodeRule<ExprSubscript> for FormatExprSubscript {
);
let format_inner = format_with(|f: &mut PyFormatter| {
if is_expression_parenthesized(value.into(), f.context().source()) {
if is_expression_parenthesized(
value.into(),
f.context().comments().ranges(),
f.context().source(),
) {
value.format().with_options(Parentheses::Always).fmt(f)
} else {
match value.as_ref() {