Introduce parenthesized helper (#5565)

This commit is contained in:
Micha Reiser 2023-07-07 11:28:25 +02:00 committed by GitHub
parent bf4b96c5de
commit 40ddc1604c
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
7 changed files with 60 additions and 64 deletions

View file

@ -1,10 +1,11 @@
use crate::builders::PyFormatterExtensions;
use crate::comments::{dangling_comments, Comments};
use crate::expression::parentheses::{
default_expression_needs_parentheses, NeedsParentheses, Parentheses, Parenthesize,
default_expression_needs_parentheses, parenthesized, NeedsParentheses, Parentheses,
Parenthesize,
};
use crate::{AsFormat, FormatNodeRule, PyFormatter};
use ruff_formatter::prelude::{format_with, group, soft_block_indent, text};
use ruff_formatter::prelude::{format_with, group, text};
use ruff_formatter::{write, Buffer, FormatResult};
use rustpython_parser::ast::ExprCall;
@ -56,7 +57,6 @@ impl FormatNodeRule<ExprCall> for FormatExprCall {
f,
[
func.format(),
text("("),
// The outer group is for things like
// ```python
// get_collection(
@ -73,8 +73,7 @@ impl FormatNodeRule<ExprCall> for FormatExprCall {
// )
// ```
// TODO(konstin): Doesn't work see wrongly formatted test
&group(&soft_block_indent(&group(&all_args))),
text(")")
parenthesized("(", &group(&all_args), ")")
]
)
}