mirror of
https://github.com/astral-sh/ruff.git
synced 2025-09-28 12:55:05 +00:00
Add optimized best_fit_parenthesize
IR (#7475)
This commit is contained in:
parent
28b48ab902
commit
6a4dbd622b
11 changed files with 413 additions and 96 deletions
|
@ -3,7 +3,7 @@ use ruff_python_ast::node::AnyNodeRef;
|
|||
use ruff_python_ast::ExprName;
|
||||
|
||||
use crate::comments::SourceComment;
|
||||
use crate::expression::parentheses::{should_use_best_fit, NeedsParentheses, OptionalParentheses};
|
||||
use crate::expression::parentheses::{NeedsParentheses, OptionalParentheses};
|
||||
use crate::prelude::*;
|
||||
|
||||
#[derive(Default)]
|
||||
|
@ -38,13 +38,9 @@ impl NeedsParentheses for ExprName {
|
|||
fn needs_parentheses(
|
||||
&self,
|
||||
_parent: AnyNodeRef,
|
||||
context: &PyFormatContext,
|
||||
_context: &PyFormatContext,
|
||||
) -> OptionalParentheses {
|
||||
if should_use_best_fit(self, context) {
|
||||
OptionalParentheses::BestFit
|
||||
} else {
|
||||
OptionalParentheses::Never
|
||||
}
|
||||
OptionalParentheses::BestFit
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue