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

Unexpected line break in subscript #814

Closed
cducrest opened this issue Apr 24, 2019 · 3 comments
Closed

Unexpected line break in subscript #814

cducrest opened this issue Apr 24, 2019 · 3 comments
Labels
F: linebreak How should we split up lines? T: style What do we want Blackened code to look like?

Comments

@cducrest
Copy link

Operating system: Linux
Python version: 3.6.7
Black version: 19.3b0
Does also happen on master: kind of

With black 19.3b0, I notice the following behaviour

# in == out:

def test_black_expected_behaviour():

    alice = pretty_long_name_but_not_too_long.action.do_something(
        action=None
    ).do_other_thing()[0]["args"]


def test_black_unexpected_behaviour():

    alice = pretty_long_name_and_actually_long_enough_to_make_it_weird.action.do_something(
        action=None
    ).do_other_thing()[
        0
    ][
        "args"
    ]

I would expect the second function to be formatted in a similar way as the first one. i tried it out with master version online

This brings the following result:

# out:

def test_black_expected_behaviour():

    alice = pretty_long_name_but_not_too_long.action.do_something(
        action=None
    ).do_other_thing()[
        0
    ][
        "args"
    ]


def test_black_unexpected_behaviour():

    alice = pretty_long_name_and_actually_long_enough_to_make_it_weird.action.do_something(
        action=None
    ).do_other_thing()[
        0
    ][
        "args"
    ]

This second result seems better because more consistent, but I am not sure it is the expected behaviour since for vertical whitespace, Black tries to render one full expression or simple statement per line. If this fits the allotted line length.

Feel free to close this issue if you consider this to be the wished for behaviour of black, or consider this as a bug / to be improved otherwise.

@JelleZijlstra JelleZijlstra added the T: style What do we want Blackened code to look like? label May 5, 2019
@JelleZijlstra JelleZijlstra changed the title Unexpected formatting behaviour Unexpected line break in subscript May 6, 2019
@zsol zsol added style and removed style labels Jul 22, 2019
@graingert
Copy link
Contributor

there seems to be a few duplicates of this:

#814
#1101
#1406

@ichard26
Copy link
Collaborator

Thank you @graingert for letting me know about those pesky duplicates! I typically don't check design issues for duplicates as clear duplicates are harder to identify. I've closed them now and marked them as duplicates.

@JelleZijlstra
Copy link
Collaborator

This is #236.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
F: linebreak How should we split up lines? T: style What do we want Blackened code to look like?
Projects
None yet
Development

No branches or pull requests

5 participants