yapf
yapf copied to clipboard
Format long list of lists
Hello,
I'm encountering an issue with how yapf handles the formatting of a very long list of lists. With my configuration file (see attached file below), the following code:
for idxs in ([1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 0], [1, 1, 0, 1, 1, 0], [1, 1, 0, 0, 1, 0], [1, 1, 1, 1, 1, 1]):
pass
is formatted by yapf as follows:
for idxs in ([1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 0], [1, 1, 0, 1, 1,
0], [1, 1, 0, 0, 1,
0], [1, 1, 1, 1, 1, 1]):
pass
which is really ugly. The expected formatting would be:
for idxs in (
[1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 0], [1, 1, 0, 1, 1, 0], [1, 1, 0, 0, 1, 0],
[1, 1, 1, 1, 1, 1]
):
pass
Similarly, if process
is a function,
process([1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 0], [1, 1, 0, 1, 1, 0], [1, 1, 0, 0, 1, 0], [1, 1, 1, 1, 1, 1])
yields:
process([1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 0], [1, 1, 0, 1, 1, 0], [1, 1, 0, 0, 1, 0],
[1, 1, 1, 1, 1, 1])
while the expected formatting (with my settings) is:
process(
[1, 1, 1, 1, 1, 1], [1, 1, 1, 1, 1, 0], [1, 1, 0, 1, 1, 0], [1, 1, 0, 0, 1, 0],
[1, 1, 1, 1, 1, 1]
)
However,
process(qdf, qdf, qdf, qdf, qdf, qdf, qdf, qdf, qdf, qdf, qdf, qdf, qdf, qdf, qdf, qdf,qdf,qdf)
is correctly formatted as expected:
process(
qdf, qdf, qdf, qdf, qdf, qdf, qdf, qdf, qdf, qdf, qdf, qdf, qdf, qdf, qdf, qdf, qdf,
qdf
)
Is this an incorrect behavior of yapf, or is it a configuration issue on my part? Thank you for your help.
Python 3.11.5 - Windows 10 x64 - yapf 0.40.1 Usage: vscode 1.84.2, eeyore 0.1.10 style.yapf.txt
Can I work on this issue? @bwendling