mirror of
https://github.com/astral-sh/ruff.git
synced 2025-09-28 21:05:08 +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
|
@ -1,4 +1,5 @@
|
|||
use crate::comments::{leading_alternate_branch_comments, trailing_comments, SourceComment};
|
||||
use crate::expression::maybe_parenthesize_expression;
|
||||
use crate::expression::parentheses::Parenthesize;
|
||||
use crate::prelude::*;
|
||||
use crate::FormatNodeRule;
|
||||
|
@ -48,7 +49,7 @@ impl FormatNodeRule<StmtIf> for FormatStmtIf {
|
|||
[
|
||||
text(current.keyword()),
|
||||
space(),
|
||||
test.format().with_options(Parenthesize::IfBreaks),
|
||||
maybe_parenthesize_expression(test, current_statement, Parenthesize::IfBreaks),
|
||||
text(":"),
|
||||
trailing_comments(if_trailing_comments),
|
||||
block_indent(&body.format())
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue