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:
Charlie Marsh 2023-07-29 10:06:26 -04:00 committed by GitHub
parent 1d7ad30188
commit 5d9814d84d
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 93 additions and 215 deletions

View file

@ -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)