Skip to content

E731: Preserve multiline string when fixing. #7720

@DerBiasto

Description

@DerBiasto

If I have this statement assigning a lambda, which returns a multiline string, to a variable:

x = lambda: """
        a
    b
"""

The automatic fix turns it into

def x():
    return "\n        a\n    b\n"

This technically preserves the whitespace correctly, but destroys readability.

I don't know if it is possible, but it would be great, if the fix could preserve the original multiline string:

def x():
    return """
        a
    b
"""

Metadata

Metadata

Assignees

No one assigned

    Labels

    fixesRelated to suggested fixes for violations

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions