Skip to content

Black removes blank lines in between a function and a decorated class in a stub file #4256

@AlexWaygood

Description

@AlexWaygood

Describe the bug

Black reformats the following .pyi stub file:

def foo(): ...

@decorator
class Bar: ...

to this:

def foo(): ...
@decorator
class Bar: ...

If Bar does not have a decorator, black permits the empty line between the two definitions. I think the empty line improves readability here quite a bit, so I'd prefer it if black would allow (or even enforce it). Decorated classes haven't historically been very common in stub files (previously, I think the only major one was maybe @final?), but we'll get more of them now that we have @deprecated: see python/typeshed#11488

Metadata

Metadata

Assignees

No one assigned

    Labels

    T: bugSomething isn't working

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions