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

Redundant parentheses around lists #608

Open
cypreess opened this issue Nov 14, 2018 · 7 comments
Open

Redundant parentheses around lists #608

cypreess opened this issue Nov 14, 2018 · 7 comments
Labels
F: parentheses Too many parentheses, not enough parentheses, and so on. S: accepted The changes in this design / enhancement issue have been accepted and can be implemented T: style What do we want Blackened code to look like?

Comments

@cypreess
Copy link

Operating system: MacOS Mojave
Python version: 3.6.6
Black version: 18.9b0
Does also happen on master: did not test

Black normally removes redundant parentheses (e.g. ((1)) -> 1) but this feature does not work for lists.

([]) -> ([]) (instead of [])
the same for using function notation
(list()) -> list()

@maciej-gol
Copy link

Same for strings: (",").join(some_names) does not get formatted to ",".join(some_names).

@zsol zsol added T: enhancement New feature or request F: parentheses Too many parentheses, not enough parentheses, and so on. labels Feb 14, 2019
@wimglenn
Copy link

wimglenn commented Mar 5, 2019

Another example:

foo(arg1=1, arg2=(
    "hello\n"
    "world"
))

bar(arg1=1, arg2=(
    "spam"
))

reformats with some strange choices

foo(arg1=1, arg2=("hello\n" "world"))

bar(arg1=1, arg2=("spam"))

@ichard26 ichard26 added T: style What do we want Blackened code to look like? S: accepted The changes in this design / enhancement issue have been accepted and can be implemented and removed T: enhancement New feature or request labels May 30, 2021
@ichard26
Copy link
Collaborator

The suggestions in the original post and also the second post are IMO reasonable to implement. So unless they are technical reasons, I doubt a PR implementing this would be rejected.

wimglenn's case is covered by #1123.

@JelleZijlstra JelleZijlstra changed the title Black does not remove redundant parentheses around a list Redundant parentheses around lists Jan 29, 2022
@oyeyipo
Copy link

oyeyipo commented Mar 30, 2022

the OP issue seems to be resolved.

@felix-hilden
Copy link
Collaborator

At least not in main: playground

@oyeyipo
Copy link

oyeyipo commented Apr 2, 2022

At least not in main: playground

They are on v22.1.0

@felix-hilden
Copy link
Collaborator

I meant that the original issue isn't fixed in main, nor in 22.1.0.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
F: parentheses Too many parentheses, not enough parentheses, and so on. S: accepted The changes in this design / enhancement issue have been accepted and can be implemented T: style What do we want Blackened code to look like?
Projects
None yet
Development

No branches or pull requests

7 participants