-
Notifications
You must be signed in to change notification settings - Fork 2.7k
Strip even more redundant for parentheses #3243
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
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,3 +1,6 @@ | ||
| for (((x))) in points: | ||
| pass | ||
|
|
||
| # Only remove tuple brackets after `for` | ||
| for (k, v) in d.items(): | ||
| print(k, v) | ||
|
|
@@ -8,6 +11,15 @@ | |
| module._verify_python3_env = lambda: None | ||
|
|
||
| # Brackets remain for long for loop lines | ||
| for (one_super_long_name_as_the_for_target_list_because_why_not_you_dont_control_me) 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: | ||
| pass | ||
|
|
||
| for ((many_long_name_tuples, many_long_name_tuples), (many_long_name_tuples, many_long_name_tuples), (many_long_name_tuples, many_long_name_tuples)) in points: | ||
| pass | ||
|
|
||
| for (why_would_anyone_choose_to_name_a_loop_variable_with_a_name_this_long, i_dont_know_but_we_should_still_check_the_behaviour_if_they_do) in d.items(): | ||
| print(k, v) | ||
|
|
||
|
|
@@ -18,7 +30,47 @@ | |
| for (((((k, v))))) in d.items(): | ||
| print(k, v) | ||
|
|
||
| # One-tuple | ||
| for (x,) in points: | ||
| pass | ||
|
|
||
| # A series of atoms that each need their brackets removed | ||
| for (x), (y) in points: | ||
| pass | ||
|
|
||
| # A mix of "simple" atoms and atoms that contain more atoms | ||
| for ((x), (y)) in points: | ||
| pass | ||
|
|
||
| for ((((x)), (((y))))) in points: | ||
| pass | ||
|
|
||
| # Mixed again; some of these brackets matter. | ||
| for ((x), (y)), z in points: | ||
| pass | ||
|
|
||
| for ((x, y), z) in points: | ||
| pass | ||
|
|
||
| for ((x, (((y)))), (((z)))) in points: | ||
| pass | ||
|
|
||
| for (((x,), (y)), ((z)),) in points: | ||
| pass | ||
|
|
||
| for ((a, b)), ((c, d)) in points: | ||
| pass | ||
|
|
||
| for ((((a), (b))), (((c), (d)))) in points: | ||
| pass | ||
|
|
||
| for (a, (b, (c, (d)))) in points: | ||
| pass | ||
|
|
||
| # output | ||
| for x in points: | ||
| pass | ||
|
|
||
| # Only remove tuple brackets after `for` | ||
| for k, v in d.items(): | ||
| print(k, v) | ||
|
|
@@ -29,6 +81,21 @@ | |
| module._verify_python3_env = lambda: None | ||
|
|
||
| # Brackets remain for long for loop lines | ||
| for ( | ||
| one_super_long_name_as_the_for_target_list_because_why_not_you_dont_control_me | ||
| ) 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 commentThe reason will be displayed to describe this comment to others. Learn more. The odd parentheses is a pre-existing bug in main. Something in |
||
| pass | ||
|
|
||
| for ( | ||
| (many_long_name_tuples, many_long_name_tuples), | ||
| (many_long_name_tuples, many_long_name_tuples), | ||
| (many_long_name_tuples, many_long_name_tuples), | ||
| ) in points: | ||
| pass | ||
|
|
||
| for ( | ||
| why_would_anyone_choose_to_name_a_loop_variable_with_a_name_this_long, | ||
| i_dont_know_but_we_should_still_check_the_behaviour_if_they_do, | ||
|
|
@@ -46,3 +113,43 @@ | |
| # Test deeply nested brackets | ||
| for k, v in d.items(): | ||
| print(k, v) | ||
|
|
||
| # One-tuple | ||
| for (x,) in points: | ||
| pass | ||
|
|
||
| # A series of atoms that each need their brackets removed | ||
| for x, y in points: | ||
| pass | ||
|
|
||
| # A mix of "simple" atoms and atoms that contain more atoms | ||
| for x, y in points: | ||
| pass | ||
|
|
||
| for x, y in points: | ||
| pass | ||
|
|
||
| # Mixed again; some of these brackets matter. | ||
| for (x, y), z in points: | ||
| pass | ||
|
|
||
| for (x, y), z in points: | ||
| pass | ||
|
|
||
| for (x, y), z in points: | ||
| pass | ||
|
|
||
| for ( | ||
| ((x,), y), | ||
| z, | ||
| ) in points: | ||
| pass | ||
|
|
||
| for (a, b), (c, d) in points: | ||
| pass | ||
|
|
||
| for (a, b), (c, d) in points: | ||
| pass | ||
|
|
||
| for a, (b, (c, d)) in points: | ||
| pass | ||
Uh oh!
There was an error while loading. Please reload this page.