-
Notifications
You must be signed in to change notification settings - Fork 2.4k
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
fix: Remove parenthesis around sole list items #4312
Open
RedGuy12
wants to merge
10
commits into
psf:main
Choose a base branch
from
RedGuy12:gh-3545
base: main
Could not load branches
Branch not found: {{ refName }}
Could not load tags
Nothing to show
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+236
−1
Open
Changes from 7 commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
183a65b
fix: Remove parenthesis around sole list items
RedGuy12 ad570d2
Merge branch 'main' of https://github.com/psf/black into gh-3545
RedGuy12 e8d291d
fix: Remove parenthesis around sole list items
RedGuy12 fd49184
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] 40140e4
Discard changes to src/black/lines.py
RedGuy12 5ceaf93
Add docs and tests for the simple cases lol
RedGuy12 cbf5730
Merge branch 'main' into gh-3545
JelleZijlstra bdb0a8a
Split into multiple features
RedGuy12 a7c9f5b
regen schema
RedGuy12 8c4519f
Merge branch 'main' into gh-3545
RedGuy12 File filter
Filter by extension
Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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
168 changes: 168 additions & 0 deletions
168
tests/data/cases/preview_remove_sole_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,168 @@ | ||
# flags: --unstable | ||
items = [(123)] | ||
items = [(True)] | ||
items = [(((((True)))))] | ||
items = [(((((True,)))))] | ||
items = [((((()))))] | ||
|
||
items = [ | ||
( | ||
{"key1": "val1", "key2": "val2", "key3": "val3"} | ||
if some_var == "longstring" | ||
else { "key": "val" } | ||
) | ||
] | ||
items = [ | ||
( | ||
{"key1": "val1", "key2": "val2", "key3": "val3"} | ||
if some_var == "longstring" | ||
else { "key": "val" } | ||
), | ||
] | ||
items = [( | ||
{"key1": "val1", "key2": "val2", "key3": "val3"} | ||
if some_var == "longstring" | ||
else { "key": "val" } | ||
)] | ||
items = [ | ||
{"key1": "val1", "key2": "val2", "key3": "val3"} | ||
if some_var == "longstring" | ||
else {"key": "val"} | ||
] | ||
items = [ | ||
( | ||
{"key1": "val1", "key2": "val2"} if some_var == "longstring" else { "key": "val" } | ||
) | ||
] | ||
items = [( | ||
{"key1": "val1", "key2": "val2"} if some_var == "" else { "key": "val" } | ||
)] | ||
items = [ | ||
{"key1": "val1", "key2": "val2"} if some_var == "longstring" else { "key": "val" } | ||
] | ||
items = [ | ||
({"key1": "val1", "key2": "val2"} if some_var == "longstring" else { "key": "val" }) | ||
] | ||
items = [({"key1": "val1", "key2": "val2"} if some_var == "" else { "key": "val" })] | ||
items = [{"key1": "val1", "key2": "val2"} if some_var == "" else { "key": "val" }] | ||
|
||
items = [ | ||
( | ||
"123456890123457890123468901234567890" | ||
if some_var == "longstrings" | ||
else "123467890123467890" | ||
) | ||
] | ||
items = [ | ||
{"key1": "val1", "key2": "val2", "key3": "val3"} | ||
and some_var == "longstring" | ||
and {"key": "val"} | ||
] | ||
items = [ | ||
( | ||
"123456890123457890123468901234567890" | ||
and some_var == "longstrings" | ||
and "123467890123467890" | ||
) | ||
] | ||
items = [( | ||
{"key1": "val1", "key2": "val2", "key3": "val3"} | ||
and some_var == "longstring" | ||
and {"key": "val"} | ||
)] | ||
|
||
|
||
items = [ | ||
( | ||
long_variable_name | ||
and even_longer_variable_name | ||
and yet_another_very_long_variable_name | ||
) | ||
] | ||
|
||
items = [ | ||
( | ||
long_variable_name | ||
and even_longer_variable_name | ||
and yet_another_very_long_variable_name | ||
), | ||
] | ||
|
||
|
||
# output | ||
items = [123] | ||
items = [True] | ||
items = [True] | ||
items = [(True,)] | ||
items = [()] | ||
|
||
items = [ | ||
{"key1": "val1", "key2": "val2", "key3": "val3"} | ||
if some_var == "longstring" | ||
else {"key": "val"} | ||
] | ||
items = [ | ||
( | ||
{"key1": "val1", "key2": "val2", "key3": "val3"} | ||
if some_var == "longstring" | ||
else {"key": "val"} | ||
), | ||
] | ||
items = [ | ||
{"key1": "val1", "key2": "val2", "key3": "val3"} | ||
if some_var == "longstring" | ||
else {"key": "val"} | ||
] | ||
items = [ | ||
{"key1": "val1", "key2": "val2", "key3": "val3"} | ||
if some_var == "longstring" | ||
else {"key": "val"} | ||
] | ||
items = [ | ||
{"key1": "val1", "key2": "val2"} if some_var == "longstring" else {"key": "val"} | ||
] | ||
items = [{"key1": "val1", "key2": "val2"} if some_var == "" else {"key": "val"}] | ||
items = [ | ||
{"key1": "val1", "key2": "val2"} if some_var == "longstring" else {"key": "val"} | ||
] | ||
items = [ | ||
{"key1": "val1", "key2": "val2"} if some_var == "longstring" else {"key": "val"} | ||
] | ||
items = [{"key1": "val1", "key2": "val2"} if some_var == "" else {"key": "val"}] | ||
items = [{"key1": "val1", "key2": "val2"} if some_var == "" else {"key": "val"}] | ||
|
||
items = [ | ||
"123456890123457890123468901234567890" | ||
if some_var == "longstrings" | ||
else "123467890123467890" | ||
] | ||
items = [ | ||
{"key1": "val1", "key2": "val2", "key3": "val3"} | ||
and some_var == "longstring" | ||
and {"key": "val"} | ||
] | ||
items = [ | ||
"123456890123457890123468901234567890" | ||
and some_var == "longstrings" | ||
and "123467890123467890" | ||
] | ||
items = [ | ||
{"key1": "val1", "key2": "val2", "key3": "val3"} | ||
and some_var == "longstring" | ||
and {"key": "val"} | ||
] | ||
|
||
|
||
items = [ | ||
long_variable_name | ||
and even_longer_variable_name | ||
and yet_another_very_long_variable_name | ||
] | ||
|
||
items = [ | ||
( | ||
long_variable_name | ||
and even_longer_variable_name | ||
and yet_another_very_long_variable_name | ||
), | ||
] |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.