-
Notifications
You must be signed in to change notification settings - Fork 1.8k
Closed
Labels
formatterRelated to the formatterRelated to the formatterhelp wantedContributions especially welcomeContributions especially welcome
Description
Our formatter currently always adds parentheses around the walrus (a := 5) operator in for/if/... cases
ruff/crates/ruff_python_formatter/src/expression/expr_named_expr.rs
Lines 32 to 41 in 3cda89e
| impl NeedsParentheses for ExprNamedExpr { | |
| fn needs_parentheses( | |
| &self, | |
| _parent: AnyNodeRef, | |
| _context: &PyFormatContext, | |
| ) -> OptionalParentheses { | |
| // Unlike tuples, named expression parentheses are not part of the range even when | |
| // mandatory. See [PEP 572](https://peps.python.org/pep-0572/) for details. | |
| OptionalParentheses::Always | |
| } |
The goal of this issue is to implement black's parentheses behavior (inside NeedsParentheses) and only preserve parentheses that are necessary.
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
formatterRelated to the formatterRelated to the formatterhelp wantedContributions especially welcomeContributions especially welcome