mirror of
https://github.com/astral-sh/ruff.git
synced 2025-07-24 13:33:50 +00:00
Remove parentheses around some walrus operators (#6173)
## Summary Closes https://github.com/astral-sh/ruff/issues/5781 ## Test Plan Added cases to `crates/ruff_python_formatter/resources/test/fixtures/ruff/expression/named_expr.py` one-by-one and adjusted the condition as needed.
This commit is contained in:
parent
1d7ad30188
commit
5d9814d84d
5 changed files with 93 additions and 215 deletions
|
@ -11,3 +11,28 @@ if (
|
|||
y0 = (y1 := f(x))
|
||||
|
||||
f(x:=y, z=True)
|
||||
|
||||
assert (x := 1)
|
||||
|
||||
|
||||
def f():
|
||||
return (x := 1)
|
||||
|
||||
|
||||
for x in (y := [1, 2, 3]):
|
||||
pass
|
||||
|
||||
async for x in (y := [1, 2, 3]):
|
||||
pass
|
||||
|
||||
del (x := 1)
|
||||
|
||||
try:
|
||||
pass
|
||||
except (e := Exception):
|
||||
if x := 1:
|
||||
pass
|
||||
|
||||
(x := 1)
|
||||
|
||||
(x := 1) + (y := 2)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue