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

% formatted arguments put on new lines after multiline strings #789

Open
hugovk opened this issue Mar 28, 2019 · 1 comment
Open

% formatted arguments put on new lines after multiline strings #789

hugovk opened this issue Mar 28, 2019 · 1 comment
Labels
F: strings Related to our handling of strings T: style What do we want Blackened code to look like?

Comments

@hugovk
Copy link
Contributor

hugovk commented Mar 28, 2019

Operating system: macOS High Sierra
Python version: 3.7.2
Black version: 19.3b0
Does also happen on master: Yes, in more cases than 19.3b0

Look how the str(err) arguments are changed.

Input

def thing():
    err = 1

    msg = """Short docstring. %s""" % (str(err))

    msg = """Short docstring. %s %s""" % (str(err), str(err))

    msg = """

    This is a long docstring. This is a long docstring. This is a long docstring. 
    This is a long docstring. This is a long docstring. This is a long docstring. %s

    """ % (str(err))

    msg = """

This is a long docstring. This is a long docstring. This is a long docstring. %s
This is a long docstring. This is a long docstring. This is a long docstring. %s

""" % (str(err), str(err))

Output with 19.3b0

The str(err) arguments are put on their own lines for long docstrings. They don't need to be changed.

def thing():
    err = 1

    msg = """Short docstring. %s""" % (str(err))

    msg = """Short docstring. %s %s""" % (str(err), str(err))

    msg = """

    This is a long docstring. This is a long docstring. This is a long docstring. 
    This is a long docstring. This is a long docstring. This is a long docstring. %s

    """ % (
        str(err)
    )

    msg = """

This is a long docstring. This is a long docstring. This is a long docstring. %s
This is a long docstring. This is a long docstring. This is a long docstring. %s

""" % (
        str(err),
        str(err),
    )

Output with master

The str(err) arguments are put on their own lines, for long docstrings, and for short docstrings when there's two of them. They don't need to be changed.

def thing():
    err = 1

    msg = """Short docstring. %s""" % (str(err))

    msg = """Short docstring. %s %s""" % (
        str(err),
        str(err),
    )

    msg = """

    This is a long docstring. This is a long docstring. This is a long docstring. 
    This is a long docstring. This is a long docstring. This is a long docstring. %s

    """ % (
        str(err)
    )

    msg = """

This is a long docstring. This is a long docstring. This is a long docstring. %s
This is a long docstring. This is a long docstring. This is a long docstring. %s

""" % (
        str(err),
        str(err),
    )

https://black.now.sh/?version=master&state=_Td6WFoAAATm1rRGAgAhARYAAAB0L-Wj4AKQAKBdAD2IimZxl1N_WlbvK5V_5XC4HPsJew3HOF1BHgQimRfSJ9q84dUyrSjb0mQnAO7rr9vjV_k61P_liPqH1s3nyKQ1P1dZ74Cja8iu64pXfCf70kAMFzhqj9sC39JI8T_XaEXuIQZyt0F1B4goQbLb0FBmreVkuA-cF_gcpYU3CTJ3yV-c-zcLZ68E2Vq_j3MdTDfxR4OlZ6ESiHDhBXbdK2AAF22UCo9c44sAAbwBkQUAAElqCpCxxGf7AgAAAAAEWVo=

@JelleZijlstra JelleZijlstra added the T: style What do we want Blackened code to look like? label May 5, 2019
@JelleZijlstra JelleZijlstra added the F: strings Related to our handling of strings label May 30, 2021
@felix-hilden felix-hilden changed the title % formatted arguments put on new lines after docstrings % formatted arguments put on new lines after multiline strings Aug 29, 2022
@RedGuy12
Copy link
Contributor

RedGuy12 commented Feb 9, 2024

This issue has been long fixed with the unstable multiline_string_handling feature.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
F: strings Related to our handling of strings T: style What do we want Blackened code to look like?
Projects
None yet
Development

No branches or pull requests

3 participants