mirror of
https://github.com/astral-sh/ruff.git
synced 2025-09-27 04:19:18 +00:00
Pass parent to NeedsParentheses
(#5708)
This commit is contained in:
parent
30702c2977
commit
067b2a6ce6
55 changed files with 562 additions and 606 deletions
|
@ -2,6 +2,7 @@ use rustpython_parser::ast::StmtAssign;
|
|||
|
||||
use ruff_formatter::write;
|
||||
|
||||
use crate::expression::maybe_parenthesize_expression;
|
||||
use crate::expression::parentheses::Parenthesize;
|
||||
use crate::prelude::*;
|
||||
use crate::FormatNodeRule;
|
||||
|
@ -26,6 +27,13 @@ impl FormatNodeRule<StmtAssign> for FormatStmtAssign {
|
|||
write!(f, [target.format(), space(), text("="), space()])?;
|
||||
}
|
||||
|
||||
write!(f, [value.format().with_options(Parenthesize::IfBreaks)])
|
||||
write!(
|
||||
f,
|
||||
[maybe_parenthesize_expression(
|
||||
value,
|
||||
item,
|
||||
Parenthesize::IfBreaks
|
||||
)]
|
||||
)
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue