mirror of
https://github.com/astral-sh/ruff
synced 2026-01-10 16:15:19 -05:00
Force parentheses for named expressions in more contexts (#6494)
See: https://github.com/astral-sh/ruff/pull/6436#issuecomment-1673583888.
This commit is contained in:
@@ -42,6 +42,21 @@ except (e := Exception):
|
||||
(x := 1)
|
||||
|
||||
(x := 1) + (y := 2)
|
||||
|
||||
with (x := 1):
|
||||
pass
|
||||
|
||||
|
||||
def f():
|
||||
yield (x := 1)
|
||||
|
||||
|
||||
def f():
|
||||
yield from (x := 1)
|
||||
|
||||
|
||||
async def f():
|
||||
await (x := 1)
|
||||
```
|
||||
|
||||
## Output
|
||||
@@ -82,6 +97,21 @@ except (e := Exception):
|
||||
(x := 1)
|
||||
|
||||
(x := 1) + (y := 2)
|
||||
|
||||
with (x := 1):
|
||||
pass
|
||||
|
||||
|
||||
def f():
|
||||
yield (x := 1)
|
||||
|
||||
|
||||
def f():
|
||||
yield from (x := 1)
|
||||
|
||||
|
||||
async def f():
|
||||
await (x := 1)
|
||||
```
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user