Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Format long list of lists #1181

Open
lolo120916 opened this issue Nov 15, 2023 · 1 comment
Open

Format long list of lists #1181

lolo120916 opened this issue Nov 15, 2023 · 1 comment

Comments

@lolo120916
Copy link

lolo120916 commented Nov 15, 2023

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

@SarthakNikhal
Copy link

SarthakNikhal commented Nov 16, 2023

Can I work on this issue? @bwendling

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants