mirror of
https://github.com/astral-sh/ruff.git
synced 2025-08-03 10:22:24 +00:00
Parenthesize NamedExpr if target breaks (#6714)
This commit is contained in:
parent
be96e0041a
commit
f017555d53
3 changed files with 22 additions and 1 deletions
|
@ -47,6 +47,13 @@ if (
|
||||||
):
|
):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
if (
|
||||||
|
x # 2
|
||||||
|
:= # 3
|
||||||
|
y
|
||||||
|
):
|
||||||
|
pass
|
||||||
|
|
||||||
y0 = (y1 := f(x))
|
y0 = (y1 := f(x))
|
||||||
|
|
||||||
f(x:=y, z=True)
|
f(x:=y, z=True)
|
||||||
|
|
|
@ -75,7 +75,7 @@ impl NeedsParentheses for ExprNamedExpr {
|
||||||
{
|
{
|
||||||
OptionalParentheses::Always
|
OptionalParentheses::Always
|
||||||
} else {
|
} else {
|
||||||
OptionalParentheses::Never
|
OptionalParentheses::Multiline
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -53,6 +53,13 @@ if (
|
||||||
):
|
):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
if (
|
||||||
|
x # 2
|
||||||
|
:= # 3
|
||||||
|
y
|
||||||
|
):
|
||||||
|
pass
|
||||||
|
|
||||||
y0 = (y1 := f(x))
|
y0 = (y1 := f(x))
|
||||||
|
|
||||||
f(x:=y, z=True)
|
f(x:=y, z=True)
|
||||||
|
@ -149,6 +156,13 @@ if (
|
||||||
):
|
):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
if (
|
||||||
|
x # 2
|
||||||
|
:= # 3
|
||||||
|
y
|
||||||
|
):
|
||||||
|
pass
|
||||||
|
|
||||||
y0 = (y1 := f(x))
|
y0 = (y1 := f(x))
|
||||||
|
|
||||||
f(x := y, z=True)
|
f(x := y, z=True)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue