-
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
fix: Remove parenthesis around sole list items #4312
base: main
Are you sure you want to change the base?
Conversation
Signed-off-by: cobalt <[email protected]>
Signed-off-by: cobalt <[email protected]>
for more information, see https://pre-commit.ci
Signed-off-by: cobalt <[email protected]>
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, these changes look good.
However, I think I'd prefer to keep feature names stable through the year. The main motivation for adding --enable-unstable-feature
was to allow users who want to keep some feature on to just turn on the feature in their config and have it keep working.
Also, I don't want to accept a PR that directly adds a new unstable style. I see the unstable style as a holding pen for style changes that we'd originally put into preview but later ran into issues with. New style features should go into preview instead.
Signed-off-by: cobalt <[email protected]>
Apologies for the delay @JelleZijlstra, I've had other priorities recently. The main issue was I put |
Signed-off-by: cobalt <[email protected]>
for more information, see https://pre-commit.ci
Hey @JelleZijlstra just returned to this PR, sorry for letting it go stale I removed this change from the unstable style, because it doesn't add any issues on its own, it just doesn't work in all cases without Do these changes look good? |
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.
Thank you!
@@ -21,6 +21,7 @@ | |||
|
|||
- Fix type annotation spacing between * and more complex type variable tuple (i.e. `def | |||
fn(*args: *tuple[*Ts, T]) -> None: pass`) (#4440) | |||
- Remove parenthesis around sole list items (#4312) |
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.
- Remove parenthesis around sole list items (#4312) | |
- Remove parentheses around sole list items (#4312) |
@@ -0,0 +1,156 @@ | |||
# flags: --unstable | |||
items = [(123)] |
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.
Add a test containing a generator expression, to make sure we don't turn it into a listcomp:
>>> [(x for x in [1])]
[<generator object <genexpr> at 0x104277400>]
>>> [x for x in [1]]
[1]
Also add tests with comments in various places (e.g., after the opening paren, before the closing paren). Such cases tend to expose bugs in Black.
Fixes #3545, but it affects more places as well.
Description
I added this to the
hug_parens_with_braces_and_square_brackets
unstable style since there was a lot of overlapping code. I renamed it toconcise_nested_brackets
to reflect this. That is a breaking change if anyone was using--enable-unstable-feature hug_parens_with_braces_and_square_brackets
, but to my knowlege, the existence of certain unstale features is not gurenteed to be stable. I can add the old name back as a (deprecated) alias or revert the rename altogether if so desired.This does introduce more places where #4036 would be triggered:
Checklist - did you ...
CHANGES.md
if necessary?