Skip to content

Formatter: inconsistent amount of added empty lines around an inner function #12199

@flying-sheep

Description

@flying-sheep

Input:

    if header[0] == "Package":
        def strengthen(k: str) -> str:
            return f"<strong>{k}</strong>"
    else:
        pass

Ruff’s output:

    if header[0] == "Package":

        def strengthen(k: str) -> str:
            return f"<strong>{k}</strong>"
    else:
        pass

Black’s output:

    if header[0] == "Package":

        def strengthen(k: str) -> str:
            return f"<strong>{k}</strong>"

    else:
        pass

I would personally prefer no empty lines to be inserted here, but matching Black’s behavior at least creates a consistent result.

Metadata

Metadata

Assignees

Labels

breakingBreaking API changebugSomething isn't workingformatterRelated to the formatter

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions