mirror of
https://github.com/astral-sh/ruff.git
synced 2025-08-22 11:24:35 +00:00
Properly group assignment targets (#5728)
This commit is contained in:
parent
f48ab2d621
commit
5dd5ee0c5b
4 changed files with 113 additions and 15 deletions
|
@ -443,6 +443,10 @@ impl<'input> PreorderVisitor<'input> for CanOmitOptionalParenthesesVisitor<'inpu
|
|||
}
|
||||
|
||||
fn has_parentheses(expr: &Expr, source: &str) -> bool {
|
||||
has_own_parentheses(expr) || is_expression_parenthesized(AnyNodeRef::from(expr), source)
|
||||
}
|
||||
|
||||
pub(crate) const fn has_own_parentheses(expr: &Expr) -> bool {
|
||||
matches!(
|
||||
expr,
|
||||
Expr::Dict(_)
|
||||
|
@ -454,7 +458,7 @@ fn has_parentheses(expr: &Expr, source: &str) -> bool {
|
|||
| Expr::DictComp(_)
|
||||
| Expr::Call(_)
|
||||
| Expr::Subscript(_)
|
||||
) || is_expression_parenthesized(AnyNodeRef::from(expr), source)
|
||||
)
|
||||
}
|
||||
|
||||
#[derive(Debug, Copy, Clone, Ord, PartialOrd, Eq, PartialEq)]
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue