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

Line break on list index in long assignment statement #391

Closed
dgouldin opened this issue Jul 2, 2018 · 2 comments
Closed

Line break on list index in long assignment statement #391

dgouldin opened this issue Jul 2, 2018 · 2 comments

Comments

@dgouldin
Copy link

dgouldin commented Jul 2, 2018

Python version: 3.6.5
Black version: 18.6b4
Does also happen on master: yes

When a list index operation happens on right side of an assignment statement that is over the character limit, black line breaks on the index operation, which IMO is awkward to read.

Before black:

some_list = ["foo"]
this_is_a_really_long_variable_name_just_to_illustrate_the_boundary_condition = some_list[0]

After black:

some_list = ["foo"]
this_is_a_really_long_variable_name_just_to_illustrate_the_boundary_condition = some_list[
    0
]

My personal preference (which is obviously just a preference):

some_list = ["foo"]
this_is_a_really_long_variable_name_just_to_illustrate_the_boundary_condition = \
    some_list[0]

If this is intended behavior, is there a PEP-related reason not to use \ in this case, or is it style choice?

@zsol
Copy link
Collaborator

zsol commented Jul 2, 2018

Hey @dgouldin, thanks for reporting!
Yes, this is definitely a bug in black. #330 and #236 talk about this already, so I'll close this out. Feel free to comment on those if you want to add more details.

As for the use of \: @ambv has a lengthy explanation of why black avoids using it here, but maybe this really should be in the readme somewhere.

@zsol zsol closed this as completed Jul 2, 2018
@zsol
Copy link
Collaborator

zsol commented Jul 2, 2018

#392 for the documentation update

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