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

newline inside bracket? #1048

Closed
makslevental opened this issue Oct 7, 2019 · 3 comments
Closed

newline inside bracket? #1048

makslevental opened this issue Oct 7, 2019 · 3 comments

Comments

@makslevental
Copy link

    sr = (out.squeeze(0).permute((1, 2, 0)).cpu().numpy()) + numpy.asarray(r2(image))[
        :, :, :3
    ] / 255

any way to avoid this?

@zsol
Copy link
Collaborator

zsol commented Oct 13, 2019

You can try putting the entire bracketed expression inside parenthesis like so:

sr = (
    (out.squeeze(0).permute((1, 2, 0)).cpu().numpy())
    + numpy.asarray(r2(image))[:, :, :3]
) / 255

But maybe the best thing for this piece of code would be to extract some sub-expressions to locals. Even with the above formatting it's hard to tell what's going on.

@zsol zsol closed this as completed Oct 13, 2019
@makslevental
Copy link
Author

But maybe the best thing for this piece of code would be to extract some sub-expressions to locals.

i mean that's for me to decide isn't it? my point is why would black format in this way.

@zsol
Copy link
Collaborator

zsol commented Oct 14, 2019

Yes, it's absolutely up to you. Black formats it this way currently because of the algorithm that's explained in the readme (right hand splitting - it starts from the right side of the expression and breaks it up).

My point with that sentence was that I don't believe there is a good way of formatting that expression as it is.

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