-
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
Strip even more redundant for parentheses #3243
base: main
Are you sure you want to change the base?
Conversation
What remains is removing unnecessary brackets because yes, you can do this: for [x, y] in points: print("this is valid code!!!") I'm leaving this as a future task because it turns out simply converting these square brackets into parentheses is not an AST-safe transformation. And`maybe_make_parens_invisible_in_atom` is currently not designed to handle square brackets and initial attemps to add a boolean `treat_square_brackets_as_parens` parameter were unsuccessful.
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.
Thanks! I wouldn't worry about square brackets; that's a different and more rarely used syntax that we can handle later if we choose to make more AST-unsafe changes.
) in points: | ||
pass | ||
|
||
for one_super_long_name_as_the_for_target_list_because_why_not_you_dont_control_me_i_have_total_freedom in (points): |
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.
The odd parentheses is a pre-existing bug in main. Something in right_hand_split
or something similar is deciding to make the invisible parentheses around points
visible even though the split failed. I'm happy to try to fix this before merging, but I probably won't get to it until September.
diff-shades is timing out, it could be simply GHA flakiness, but there could be a genuine infinite loop (or massive slowdown) somewhere. Since I'm in no rush to land this I'll mark this as draft. |
Description
Fixes #3080.
What remains is removing unnecessary brackets because yes, you can do this:
I'm leaving this as a future task because it turns out simply converting these square brackets into parentheses is not an AST-safe transformation so letting the pre-existing logic handle the rest doesn't work. And
maybe_make_parens_invisible_in_atom
is currently not designed to handle square brackets and initial attempts to add a booleantreat_square_brackets_as_parens
parameter were unsuccessful.Checklist - did you ...