Skip to content

Formatter: stub files only have one empty lines between top level items #5821

@konstin

Description

@konstin

Black only formats one empty line between top level items in stub files (.pyi), while it uses two empty lines in regular python files. When single line classes, method and functions of the same kind that are stubbed out with ellipses follow each they don't get any empty lines.

scratch.py

class A:
    def __init__(self):
        pass


class B:
    def __init__(self):
        pass


def foo():
    pass


class Del(expr_context):
    ...


class Load(expr_context):
    ...


class Store(expr_context):
    ...

scratch.pyi

class A:
    def __init__(self):
        pass

class B:
    def __init__(self):
        pass

def foo():
    pass

class Del(expr_context): ...
class Load(expr_context): ...
class Store(expr_context): ...

The relevant code is below, which doesn't have access to whether it's in a stub file or not yet.

&format_args![empty_line(), empty_line()],

Metadata

Metadata

Assignees

No one assigned

    Labels

    formatterRelated to the formattergood first issueGood for newcomershelp wantedContributions especially welcome

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions