mirror of
https://github.com/astral-sh/ruff.git
synced 2025-11-25 05:35:58 +00:00
Don't "flatten" nested if expressions when formatting (#6996)
This commit is contained in:
parent
b404e54f33
commit
31947af6a3
4 changed files with 305 additions and 25 deletions
|
|
@ -39,3 +39,72 @@ d1 = [
|
|||
("b") else # 2
|
||||
("c")
|
||||
]
|
||||
|
||||
e1 = (
|
||||
a
|
||||
if True # 1
|
||||
else b
|
||||
if False # 2
|
||||
else c
|
||||
)
|
||||
|
||||
|
||||
# Flattening nested if-expressions.
|
||||
def something():
|
||||
clone._iterable_class = (
|
||||
NamedValuesListIterable
|
||||
if named
|
||||
else FlatValuesListIterable
|
||||
if flat
|
||||
else ValuesListIterable
|
||||
)
|
||||
|
||||
|
||||
def something():
|
||||
clone._iterable_class = (
|
||||
(NamedValuesListIterable
|
||||
if named
|
||||
else FlatValuesListIterable)
|
||||
if flat
|
||||
else ValuesListIterable
|
||||
)
|
||||
|
||||
|
||||
def something():
|
||||
clone._iterable_class = (
|
||||
NamedValuesListIterable
|
||||
if named
|
||||
else (FlatValuesListIterable
|
||||
if flat
|
||||
else ValuesListIterable)
|
||||
)
|
||||
|
||||
|
||||
def something():
|
||||
clone._iterable_class = (
|
||||
NamedValuesListIterable
|
||||
if named
|
||||
else FlatValuesListIterable(1,)
|
||||
if flat
|
||||
else ValuesListIterable
|
||||
)
|
||||
|
||||
|
||||
def something():
|
||||
clone._iterable_class = (
|
||||
NamedValuesListIterable
|
||||
if named
|
||||
else FlatValuesListIterable + FlatValuesListIterable + FlatValuesListIterable + FlatValuesListIterable
|
||||
if flat
|
||||
else ValuesListIterable
|
||||
)
|
||||
|
||||
|
||||
def something():
|
||||
clone._iterable_class = (
|
||||
NamedValuesListIterable
|
||||
if named
|
||||
else (FlatValuesListIterable + FlatValuesListIterable + FlatValuesListIterable + FlatValuesListIterable
|
||||
if flat
|
||||
else ValuesListIterable)
|
||||
)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue