Skip to content

Blank lines before class docstring are not removed #3659

@jonathanberthias

Description

@jonathanberthias

Describe the style change

The blank lines between a function's definition and its docstring currently get removed by Black. However, it does not do the same thing for classes.

Current Black changes

def f():

    """The line above gets removed."""
    return 0

becomes

def f():
    """The line above gets removed."""
    return 0

but

class C:

    """The line above stays."""

is not modified by Black.

Desired style

I would have expected that code to get reformatted as:

class C:
    """The line above stays."""

Metadata

Metadata

Assignees

No one assigned

    Labels

    F: empty linesWasting vertical space efficiently.S: acceptedThe changes in this design / enhancement issue have been accepted and can be implementedT: styleWhat do we want Blackened code to look like?

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions