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

Formatting heavily nested code #626

Closed
klahnakoski opened this issue Nov 28, 2018 · 1 comment
Closed

Formatting heavily nested code #626

klahnakoski opened this issue Nov 28, 2018 · 1 comment

Comments

@klahnakoski
Copy link

This is a please-change-formatting request. I do not think it conflicts with existing rules.

Here is a piece of code that Black formatted, but it is a bit ugly:

    config = Config(
        **unwrap(
            set_default(
                {},
                config,
                {
                    "overrides": {
                        "run": {
                            # "hide": True,
                            "out_stream": self.stdout,
                            "err_stream": self.stderr,
                        }
                    }
                },
            )
        )
    )

If there is only one item enclosed in brackets, we can put it on the same line as the opening bracket:

    config = Config(**unwrap(set_default(
        {},
        config,
        {"overrides": {"run": {
            # "hide": True,
            "out_stream": self.stdout,
            "err_stream": self.stderr,
        }}},
    )))

Thank you.

@zsol zsol changed the title minimize lines with only one closing parenthesis/bracket/brace Formatting heavily nested code Dec 4, 2018
@zsol
Copy link
Collaborator

zsol commented Dec 4, 2018

I don't think the proposed formatting is more readable at all. In fact, I think both of them are pretty unreadable because of the amount of nesting going on.

There's not much Black can do about this in my opinion.

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

No branches or pull requests

2 participants