-
Notifications
You must be signed in to change notification settings - Fork 2.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: Remove parenthesis around sole list items (#4312)
- Loading branch information
Showing
7 changed files
with
436 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
158 changes: 158 additions & 0 deletions
158
tests/data/cases/preview_remove_lone_list_item_parens.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,158 @@ | ||
# flags: --preview | ||
items = [(123)] | ||
items = [(True)] | ||
items = [(((((True)))))] | ||
items = [(((((True,)))))] | ||
items = [((((()))))] | ||
items = [(x for x in [1])] | ||
items = {(123)} | ||
items = {(True)} | ||
items = {(((((True)))))} | ||
|
||
# Requires `hug_parens_with_braces_and_square_brackets` unstable style to remove parentheses | ||
# around multiline values | ||
items = [ | ||
( | ||
{"key1": "val1", "key2": "val2", "key3": "val3"} | ||
if some_var == "long strings" | ||
else {"key": "val"} | ||
) | ||
] | ||
items = [ | ||
( | ||
{"key1": "val1", "key2": "val2"} | ||
if some_var == "" | ||
else {"key": "val"} | ||
) | ||
] | ||
|
||
# Comments should not cause crashes | ||
items = [ | ||
( # comment | ||
{"key1": "val1", "key2": "val2", "key3": "val3"} | ||
if some_var == "long strings" | ||
else {"key": "val"} | ||
) | ||
] | ||
items = [ | ||
( | ||
{"key1": "val1", "key2": "val2", "key3": "val3"} | ||
if some_var == "long strings" | ||
else {"key": "val"} | ||
) # comment | ||
] | ||
|
||
items = [ # comment | ||
( | ||
{"key1": "val1", "key2": "val2", "key3": "val3"} | ||
if some_var == "long strings" | ||
else {"key": "val"} | ||
) | ||
] | ||
items = [ | ||
( | ||
{"key1": "val1", "key2": "val2", "key3": "val3"} | ||
if some_var == "long strings" | ||
else {"key": "val"} | ||
) | ||
] # comment | ||
|
||
items = [ | ||
( | ||
{"key1": "val1", "key2": "val2", "key3": "val3"} # comment | ||
if some_var == "long strings" | ||
else {"key": "val"} | ||
) | ||
] | ||
|
||
items = [ # comment | ||
( # comment | ||
{"key1": "val1", "key2": "val2", "key3": "val3"} | ||
if some_var == "long strings" | ||
else {"key": "val"} | ||
) | ||
] | ||
items = [ | ||
( | ||
{"key1": "val1", "key2": "val2", "key3": "val3"} | ||
if some_var == "long strings" | ||
else {"key": "val"} | ||
) # comment | ||
] # comment | ||
|
||
|
||
# output | ||
items = [123] | ||
items = [True] | ||
items = [True] | ||
items = [(True,)] | ||
items = [()] | ||
items = [(x for x in [1])] | ||
items = {123} | ||
items = {True} | ||
items = {True} | ||
|
||
# Requires `hug_parens_with_braces_and_square_brackets` unstable style to remove parentheses | ||
# around multiline values | ||
items = [ | ||
( | ||
{"key1": "val1", "key2": "val2", "key3": "val3"} | ||
if some_var == "long strings" | ||
else {"key": "val"} | ||
) | ||
] | ||
items = [{"key1": "val1", "key2": "val2"} if some_var == "" else {"key": "val"}] | ||
|
||
# Comments should not cause crashes | ||
items = [ | ||
( # comment | ||
{"key1": "val1", "key2": "val2", "key3": "val3"} | ||
if some_var == "long strings" | ||
else {"key": "val"} | ||
) | ||
] | ||
items = [ | ||
( | ||
{"key1": "val1", "key2": "val2", "key3": "val3"} | ||
if some_var == "long strings" | ||
else {"key": "val"} | ||
) # comment | ||
] | ||
|
||
items = [ # comment | ||
( | ||
{"key1": "val1", "key2": "val2", "key3": "val3"} | ||
if some_var == "long strings" | ||
else {"key": "val"} | ||
) | ||
] | ||
items = [ | ||
( | ||
{"key1": "val1", "key2": "val2", "key3": "val3"} | ||
if some_var == "long strings" | ||
else {"key": "val"} | ||
) | ||
] # comment | ||
|
||
items = [ | ||
( | ||
{"key1": "val1", "key2": "val2", "key3": "val3"} # comment | ||
if some_var == "long strings" | ||
else {"key": "val"} | ||
) | ||
] | ||
|
||
items = [ # comment | ||
( # comment | ||
{"key1": "val1", "key2": "val2", "key3": "val3"} | ||
if some_var == "long strings" | ||
else {"key": "val"} | ||
) | ||
] | ||
items = [ | ||
( | ||
{"key1": "val1", "key2": "val2", "key3": "val3"} | ||
if some_var == "long strings" | ||
else {"key": "val"} | ||
) # comment | ||
] # comment |
Oops, something went wrong.