Parenthesize NamedExpr if target breaks (#6714)

This commit is contained in:
Micha Reiser 2023-08-21 16:29:26 +02:00 committed by GitHub
parent be96e0041a
commit f017555d53
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 22 additions and 1 deletions

View file

@ -47,6 +47,13 @@ if (
):
pass
if (
x # 2
:= # 3
y
):
pass
y0 = (y1 := f(x))
f(x:=y, z=True)

View file

@ -75,7 +75,7 @@ impl NeedsParentheses for ExprNamedExpr {
{
OptionalParentheses::Always
} else {
OptionalParentheses::Never
OptionalParentheses::Multiline
}
}
}

View file

@ -53,6 +53,13 @@ if (
):
pass
if (
x # 2
:= # 3
y
):
pass
y0 = (y1 := f(x))
f(x:=y, z=True)
@ -149,6 +156,13 @@ if (
):
pass
if (
x # 2
:= # 3
y
):
pass
y0 = (y1 := f(x))
f(x := y, z=True)