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

[BUG] yapf with split_all_top_level_comma_separated_values set to true fails to split lines with tuple LHS #1203

Open
dnns92 opened this issue Feb 20, 2024 · 1 comment

Comments

@dnns92
Copy link

dnns92 commented Feb 20, 2024

Dear yapf-team,

for this code snippet, one would expect to receive a roughly same treatment of these two statements:

test.py

x, = some_long_enough_function_to_cause_a_linebreak(very_long_arg1, very_long_arg_2, an_extemly_loooooooooooooooooooooooong_argument)
x = some_long_enough_function_to_cause_a_linebreak(very_long_arg1, very_long_arg_2, an_extemly_looooooooooooooooooooooooong_argument)

However, after running yapf --style .\.style.yapf -rip test.py with the .style.yapf:

[style]
based_on_style = pep8
column_limit = 120
split_all_top_level_comma_separated_values = true

We receive:

x, = some_long_enough_function_to_cause_a_linebreak(very_long_arg1, very_long_arg_2, an_extemly_loooooooooooooooooooooooong_argument)

x = some_long_enough_function_to_cause_a_linebreak(very_long_arg1,
                                                   very_long_arg_2,
                                                   an_extemly_loooooooooooooooooooooooong_argument)

Expectation:

x, = some_long_enough_function_to_cause_a_linebreak(very_long_arg1,
                                                    very_long_arg_2,
                                                    an_extemly_looooooooooooooooooooooooong_argument)

x = some_long_enough_function_to_cause_a_linebreak(very_long_arg1,
                                                   very_long_arg_2,
                                                   an_extemly_loooooooooooooooooooooooong_argument)

I experimented a bit and saw that this issue arises only when split_all_top_level_comma_separated_values is true. This cannot be fixed by using syntax like x, _ = or x, y = . A workaround is however to put enclosing brackets around the LHS like (x,) = or (x, _) = .

However, the fix seems to produce this weird effect as well:

(x111, y222) = my_very_long_call_bla(my_very_long_arg, my_very_long_arg, my_very_long_arg, my_very_looooooooooooooong_arg)

turns into

(x111,
 y222) = my_very_long_call_bla(my_very_long_arg, my_very_long_arg, my_very_long_arg, my_very_looooooooooooooong_arg)

instead of how one would expect it:

(x111, y222) = my_very_long_call_bla(
    my_very_long_arg, my_very_long_arg, my_very_long_arg, my_very_looooooooooooooong_arg
)
@dnns92 dnns92 changed the title yapf with split_all_top_level_comma_separated_values set to true fails to split lines on tuple LHS yapf with split_all_top_level_comma_separated_values set to true fails to split lines with tuple LHS Feb 20, 2024
@dnns92 dnns92 changed the title yapf with split_all_top_level_comma_separated_values set to true fails to split lines with tuple LHS [BUG] yapf with split_all_top_level_comma_separated_values set to true fails to split lines with tuple LHS Feb 26, 2024
@97gamjak
Copy link

Was there any progress on this issue?

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