Skip to content

Formatter: allow_empty_first_line_before_new_block_or_comment preview style #8893

@MichaReiser

Description

@MichaReiser

Implement Black's allow_empty_first_line_before_new_block_or_comment as a Ruff preview style.

def foo():
    """
    Docstring
    """

    # Here we go
    if x:

        # This is also now fine
        a = 123

    else:
        # But not necessary
        a = 123

Notice how black now allows empty lines before the comments. Ruff seems to support this sometimes.

Goal: Implement the new formatting behind the preview flag and import the Black tests.

Metadata

Metadata

Assignees

No one assigned

    Labels

    formatterRelated to the formatterpreviewRelated to preview mode features

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions