-
Notifications
You must be signed in to change notification settings - Fork 2.4k
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
Question on binary operator linebreaking #587
Comments
For reference the line break should be before the operator like this: assert (
espec.EncodingSpec("e:{A6D4CFE470214878,FD4466FC,n}")
== espec.EncodingSpec("e:{A6D4CFE470214878,FD4466FC,n}")
) I have seen the same happen with if statements and personally would prefer this outcome: if (
very_long_long_long_long_func('argument')
or other_very_long_long_long_func('argument')
):
pass to current output: if very_long_long_long_long_func("argument") or other_very_long_long_long_func(
"argument"
):
pass Somewhat related to issue #571 |
I have a code snippet as follows: looks_like_pep = (
file_path.startswith("pep-") and
file_path.endswith((".txt", "rst")
) With line length 79, looks_like_pep = file_path.startswith("pep-") and file_path.endswith(
(".txt", "rst")
) Reducing the line length to 75 re-formats the code to: looks_like_pep = file_path.startswith(
"pep-"
) and file_path.endswith((".txt", "rst")) Both outputs are worse IMO than the input here. ISTM, black more readily breaks around parenthesis than around a binary logical operator. |
I'll close this as a duplicate of #2156. |
Operating system: Linux
Python version: 3.7
Black version: Master
I have the following code:
This gets reformatted to the following:
The latter is the simpler way to linebreak but is IMO a lot less readable (especially in the case of tests). Is there a case to be made to prefer the former style? I believe that's also how prettier prefers linebreaking as it's a lot more readable in general.
The text was updated successfully, but these errors were encountered: