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

Keep distinct bracket types together when sole inner expression exceeds one line #1339

Closed
twosigmajab opened this issue Apr 9, 2020 · 2 comments
Labels
R: duplicate This issue or pull request already exists T: style What do we want Blackened code to look like?

Comments

@twosigmajab
Copy link

Current format:

frozenset(                                                                              
    {                                                                                                                                                                    
        0,                                                                              
        1,                                                                              
        2,                                                                              
        3,                                                                              
        ...,   # (continues in sequence, omitted for brevity)
        23,                                                                             
    }                                                                                   
)                                                                                       

Proposed format:

frozenset({                                                                              
    0,                                                                                   
    1,                                                                                   
    2,                                                                                   
    3,                                                                                   
    ...,                                                                                 
    23,                                                                                                                                                                  
})

This is a very common construct. The distinct bracket types provide enough differentiation between the inner and the outer expression; the extra level of indentation is just noise.

Looks tangentially-related: #177

@ichard26 ichard26 added the T: style What do we want Blackened code to look like? label Aug 4, 2020
@jab
Copy link

jab commented May 10, 2021

Also seems worth noting that in practice the expressions on each line are often longer than in this example (numbers from 0 to 23), so saving the extra level of indentation here can end up eliminating the need for the inner expressions to overflow into multiple lines, and other cascading effects that ultimately make it harder to read code that black is currently producing.

Is this an issue that a new contributor might be able to fix (potentially with some pointers on how to get started)? Thanks:)

@ichard26 ichard26 added the R: duplicate This issue or pull request already exists label May 30, 2021
@ichard26
Copy link
Collaborator

While this is older than #2071, I feel like it has more context so I'll be closing this in favour of that. I'll copy over the context provided here though.

Oh and thank you for the suggestion!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
R: duplicate This issue or pull request already exists T: style What do we want Blackened code to look like?
Projects
None yet
Development

No branches or pull requests

3 participants