-
Notifications
You must be signed in to change notification settings - Fork 2.5k
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
Prefer splitting right hand side of assignment statements. #3368
Conversation
diff-shades results comparing this PR (bcc8075) to main (a282181). The full diff is available in the logs under the "Generate HTML diff report" step.
|
Looking at the diff-shades results, I need to fix the following isuses:
- (
- field,
- targets,
- alias,
- joins,
- path,
- opts,
- transform_function,
- ) = self._setup_joins(pieces, opts, alias)
+ (field, targets, alias, joins, path, opts, transform_function,) = (
+ self._setup_joins(pieces, opts, alias)
+ )
clone.external_aliases[alias] = (
- isinstance(table, Join)
- and table.join_field.related_model._meta.db_table != alias
- ) or (
- isinstance(table, BaseTable) and table.table_name != table.table_alias
+ (
+ isinstance(table, Join)
+ and table.join_field.related_model._meta.db_table != alias
+ )
+ or (
+ isinstance(table, BaseTable)
+ and table.table_name != table.table_alias
+ )
)
y_hat_discrete[
np.arange(y_hat_probas.shape[0]), y_hat_probas.argmax(axis=1)
- ] = 1
+ ] = (1) |
I was going to point out 1. but you beat me :) I don't think 2. is a problem: the parentheses around each |
I noticed this one:
which I realize is another example of what you meant by 2. |
Also wanted to mention that most of the changes in diff-shades are clear improvements. This is going to be a positive change. |
Adding a note, looks like the handling of trailing comma on the left side is related to an existing issue: (
a,
b,
c,
d,
) = func1(arg1)
(a, b, c, d,) = func1(
arg1
) and func2(arg2) Maybe #1671? |
…erred. The logic is implemented in the _prefer_split_rhs_oop function.
The three issues mentioned above are now fixed, this is ready to review again. |
This Cherrypicks the changes from psf#3368 before this can be merged upstream. PiperOrigin-RevId: 493104368
Kindly ping? @JelleZijlstra |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looked over diff-shades again and everything looks good.
Adding skip fmt to avoid issues with black < 24. New rule added in black 24 is: > If an assignment statement is too long, we now prefer splitting on the right-hand side > psf/black#3368
Adding skip fmt to avoid issues with black < 24. New rule added in black 24 is: > If an assignment statement is too long, we now prefer splitting on the right-hand side > psf/black#3368
Adding skip fmt to avoid issues with black < 24. New rule added in black 24 is: > If an assignment statement is too long, we now prefer splitting on the right-hand side > psf/black#3368
Description
When an assignment statement's left hand side fits on a single line, prefer splitting the right hand side's outer optional parens.
Fixes #1498.
Checklist - did you ...
CHANGES.md
if necessary?