mirror of
https://github.com/astral-sh/ruff.git
synced 2025-08-04 18:58:04 +00:00
Correct parenthesized long nested-expressions example to match Ruff's output (#12153)
This commit is contained in:
parent
7c8112614a
commit
adfd78e05a
1 changed files with 26 additions and 22 deletions
|
@ -91,37 +91,41 @@ Black 24 and newer parenthesizes long conditional expressions and type annotatio
|
|||
),
|
||||
]
|
||||
|
||||
|
||||
def foo(
|
||||
i: int,
|
||||
x: (
|
||||
Loooooooooooooooooooooooong
|
||||
| Looooooooooooooooong
|
||||
| Looooooooooooooooooooong
|
||||
| Looooooong
|
||||
),
|
||||
*,
|
||||
s: str,
|
||||
i: int,
|
||||
x: (
|
||||
Loooooooooooooooooooooooong
|
||||
| Looooooooooooooooong
|
||||
| Looooooooooooooooooooong
|
||||
| Looooooong
|
||||
),
|
||||
*,
|
||||
s: str,
|
||||
) -> None:
|
||||
pass
|
||||
pass
|
||||
|
||||
# Ruff
|
||||
[
|
||||
"____________________________",
|
||||
"foo",
|
||||
"bar",
|
||||
"baz" if some_really_looooooooong_variable else "some other looooooooooooooong value"
|
||||
"____________________________",
|
||||
"foo",
|
||||
"bar",
|
||||
"baz"
|
||||
if some_really_looooooooong_variable
|
||||
else "some other looooooooooooooong value",
|
||||
]
|
||||
|
||||
|
||||
def foo(
|
||||
i: int,
|
||||
x: Loooooooooooooooooooooooong
|
||||
| Looooooooooooooooong
|
||||
| Looooooooooooooooooooong
|
||||
| Looooooong,
|
||||
*,
|
||||
s: str,
|
||||
i: int,
|
||||
x: Loooooooooooooooooooooooong
|
||||
| Looooooooooooooooong
|
||||
| Looooooooooooooooooooong
|
||||
| Looooooong,
|
||||
*,
|
||||
s: str,
|
||||
) -> None:
|
||||
pass
|
||||
pass
|
||||
```
|
||||
|
||||
We agree that Ruff's formatting (that matches Black's 23) is hard to read and needs improvement. But we aren't convinced that parenthesizing long nested expressions is the best solution, especially when considering expression formatting holistically. That's why we want to defer the decision until we've explored alternative nested expression formatting styles. See [psf/Black#4123](https://github.com/psf/black/issues/4123) for an in-depth explanation of our concerns and an outline of possible alternatives.
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue