-
Notifications
You must be signed in to change notification settings - Fork 1.8k
Closed
Labels
formatterRelated to the formatterRelated to the formatter
Description
Assignment expressions are those using the "walrus operator" :=:
if x := f():
g(x)In general, they are easy to format, they are a sequence of target, space, :=, space, value with optional parentheses.
The difficulty is that there are a list of exceptional cases in PEP 572 where the parentheses are mandatory based on the surrounding node, e.g. keyword argument values need parentheses. So for implementing this we either need to use the tuple way of checking if there are parentheses in range or each node in the list in PEP 572 needs to have a special case where it checks whether the expression it is about to format is a ExprNamedExpr and in that cases sets the parentheses to always.
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
formatterRelated to the formatterRelated to the formatter