Skip to content
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
wants to merge 7 commits into
base: main
Choose a base branch
from

Conversation

RedGuy12
Copy link
Contributor

@RedGuy12 RedGuy12 commented Apr 17, 2024

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 to concise_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:

items = [  # type: ignore
    (  # type: ignore
        {"key1": "val1", "key2": "val2", "key3": "val3"}
        if some_var == "longstring"
        else { "key": "val" }
    )
]

Checklist - did you ...

  • [y] Add an entry in CHANGES.md if necessary?
  • [y] Add / update tests if necessary?
  • [y] Add new / update outdated documentation?

Signed-off-by: cobalt <61329810+RedGuy12@users.noreply.github.com>
Copy link

github-actions bot commented Apr 17, 2024

diff-shades reports zero changes comparing this PR (cbf5730) to main (2f88085).


What is this? | Workflow run | diff-shades documentation

@@ -124,6 +124,55 @@ foo(
)
```

Parenthesises around sole list items will also be removed for similar reasons. Trailing
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
Parenthesises around sole list items will also be removed for similar reasons. Trailing
Parentheses around sole list items will also be removed for similar reasons. Trailing

Copy link
Collaborator

@JelleZijlstra JelleZijlstra left a 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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

A single conditional expression inside a list is unnecessarily parenthesized
2 participants