mirror of
https://github.com/astral-sh/ruff.git
synced 2025-08-03 18:28:24 +00:00
Handle implicit strings in `can_omit_parentheses (#6940)
This commit is contained in:
parent
9c98416b96
commit
60097bebcd
1 changed files with 20 additions and 3 deletions
|
@ -8,7 +8,7 @@ use ruff_formatter::{
|
|||
use ruff_python_ast as ast;
|
||||
use ruff_python_ast::node::AnyNodeRef;
|
||||
use ruff_python_ast::visitor::preorder::{walk_expr, PreorderVisitor};
|
||||
use ruff_python_ast::{Expr, ExpressionRef, Operator};
|
||||
use ruff_python_ast::{Constant, Expr, ExpressionRef, Operator};
|
||||
|
||||
use crate::builders::parenthesize_if_expands;
|
||||
use crate::comments::leading_comments;
|
||||
|
@ -521,6 +521,25 @@ impl<'input> CanOmitOptionalParenthesesVisitor<'input> {
|
|||
return;
|
||||
}
|
||||
|
||||
Expr::Constant(ast::ExprConstant {
|
||||
value:
|
||||
Constant::Str(ast::StringConstant {
|
||||
implicit_concatenated: true,
|
||||
..
|
||||
})
|
||||
| Constant::Bytes(ast::BytesConstant {
|
||||
implicit_concatenated: true,
|
||||
..
|
||||
}),
|
||||
..
|
||||
})
|
||||
| Expr::FString(ast::ExprFString {
|
||||
implicit_concatenated: true,
|
||||
..
|
||||
}) => {
|
||||
self.update_max_priority(OperatorPriority::String);
|
||||
}
|
||||
|
||||
Expr::NamedExpr(_)
|
||||
| Expr::GeneratorExp(_)
|
||||
| Expr::Lambda(_)
|
||||
|
@ -767,8 +786,6 @@ enum OperatorPriority {
|
|||
BitwiseAnd,
|
||||
BitwiseOr,
|
||||
BitwiseXor,
|
||||
// TODO(micha)
|
||||
#[allow(unused)]
|
||||
String,
|
||||
BooleanOperation,
|
||||
Conditional,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue