-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
Formatter: Allow comments between and
/or
and the right hand side
#6062
Comments
We may want to generalize the formatting of all BinaryLike nodes to achieve consistent formatting. |
I actually prefer our formatting over black's and it preserves the comment ordering. But we should align the comment placement for all binary like expressions. |
I agree with Micha that our formatting is more readable at the expense of possibly overriding user intent. I don't see what extra context can be given by having the comment after the operator though. |
I guess the challenge with the current formatting is how to handle trailing I think my preferred formatting is: if (
a
# own line comment between left hand side and `and`
# trailing
# own line comment between `and` and right hand side
and b
):
pass It preserves the order, but changes Edit: Similar issue #6647 |
And this is another funny one CC: @charliermarsh You best run our formatter on |
I can take it on. |
Thank you @charliermarsh If possible, could we align the comment handling with the binary expression formatting? It's very likely that I have to unify the two implementations and that would be significantly easier if they roughly work the same. |
It turns out that the string formatting doesn't overlap with Overall, the binary / compare formatting seems very reasonable. Maybe we can mimick that formatting for boolean expressions |
@charliermarsh do you plan to work on this next week? If not, @konstin would you be interested in taking a look. It's our biggest difference in Django by now or I'll try to have a look since it's related to binary expression formatting. |
@konstin - please go ahead! Haven’t started on it at all. |
The following input is stable with black ...
... but we move the second own line comment before the
and
:The behavior is the same with
or
, but+
works, i.e. other binary expressions work but not boolean expressions.The text was updated successfully, but these errors were encountered: