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

Long method chaining inside a dictionary looks bad #2591

Closed
archiif opened this issue Nov 5, 2021 · 1 comment
Closed

Long method chaining inside a dictionary looks bad #2591

archiif opened this issue Nov 5, 2021 · 1 comment
Labels
F: parentheses Too many parentheses, not enough parentheses, and so on. R: duplicate This issue or pull request already exists T: style What do we want Blackened code to look like?

Comments

@archiif
Copy link

archiif commented Nov 5, 2021

Describe the style change

Break up and indent long method chaining inside a dictionary in a more readable way

Examples in the current Black style

How black breaks up method chaining in variable assignments:

value = (
    fn.chain()
    .chain()
    .chain()
    .chain()
    .chain()
    .chain()
    .chain()
    .chain()
    .chain()
    .chain()
    .chain()
)

How black does it with dictionary key assignments:

d = {
    foo: fn.chain()
    .chain()
    .chain()
    .chain()
    .chain()
    .chain()
    .chain()
    .chain()
    .chain()
    .chain(),
    bar: "value",
    more: "stuff",
}

Desired style

d = {
    foo: (
        fn.chain()
        .chain()
        .chain()
        .chain()
        .chain()
        .chain()
        .chain()
        .chain()
        .chain()
        .chain()
    ),
    bar: "value",
    more: "stuff",
}

or maybe:

d = {
    foo: fn.chain()
        .chain()
        .chain()
        .chain()
        .chain()
        .chain()
        .chain()
        .chain()
        .chain()
        .chain(),
    bar: "value",
    more: "stuff",
}

Additional context

@archiif archiif added the T: style What do we want Blackened code to look like? label Nov 5, 2021
@felix-hilden
Copy link
Collaborator

Hi, this is a duplicate of #620, we'll continue the discussion there!

@felix-hilden felix-hilden added F: parentheses Too many parentheses, not enough parentheses, and so on. R: duplicate This issue or pull request already exists labels Nov 5, 2021
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. 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

2 participants