diff --git a/crates/ruff_python_formatter/src/expression/expr_call.rs b/crates/ruff_python_formatter/src/expression/expr_call.rs index af4fa6b21b..2372b4a577 100644 --- a/crates/ruff_python_formatter/src/expression/expr_call.rs +++ b/crates/ruff_python_formatter/src/expression/expr_call.rs @@ -1,6 +1,8 @@ use ruff_formatter::write; +use ruff_python_ast::node::AnyNodeRef; use ruff_python_ast::ExprCall; +use crate::expression::parentheses::{NeedsParentheses, OptionalParentheses}; use crate::prelude::*; use crate::FormatNodeRule; @@ -18,3 +20,13 @@ impl FormatNodeRule for FormatExprCall { write!(f, [func.format(), arguments.format()]) } } + +impl NeedsParentheses for ExprCall { + fn needs_parentheses( + &self, + _parent: AnyNodeRef, + context: &PyFormatContext, + ) -> OptionalParentheses { + self.func.needs_parentheses(self.into(), context) + } +} diff --git a/crates/ruff_python_formatter/src/other/arguments.rs b/crates/ruff_python_formatter/src/other/arguments.rs index 4aeefa5f0a..e99c31807c 100644 --- a/crates/ruff_python_formatter/src/other/arguments.rs +++ b/crates/ruff_python_formatter/src/other/arguments.rs @@ -1,15 +1,13 @@ use ruff_formatter::write; -use ruff_python_ast::node::{AnyNodeRef, AstNode}; -use ruff_python_ast::{Arguments, Expr, ExprCall, Ranged}; +use ruff_python_ast::node::AstNode; +use ruff_python_ast::{Arguments, Expr, Ranged}; use ruff_python_trivia::{SimpleTokenKind, SimpleTokenizer}; use ruff_text_size::{TextRange, TextSize}; use crate::builders::empty_parenthesized_with_dangling_comments; use crate::comments::trailing_comments; use crate::expression::expr_generator_exp::GeneratorExpParentheses; -use crate::expression::parentheses::{ - parenthesized, NeedsParentheses, OptionalParentheses, Parentheses, -}; +use crate::expression::parentheses::{parenthesized, Parentheses}; use crate::prelude::*; use crate::FormatNodeRule; @@ -116,16 +114,6 @@ impl FormatNodeRule for FormatArguments { } } -impl NeedsParentheses for ExprCall { - fn needs_parentheses( - &self, - _parent: AnyNodeRef, - context: &PyFormatContext, - ) -> OptionalParentheses { - self.func.needs_parentheses(self.into(), context) - } -} - fn is_single_argument_parenthesized(argument: &Expr, call_end: TextSize, source: &str) -> bool { let mut has_seen_r_paren = false;