Skip to content

The latest behavior of empty lines is NOT reflected in the current code style documentation #4238

@FanchenBao

Description

@FanchenBao

Is this related to a problem? Please describe.

There has been some back-and-forth regarding empty line after code block open recently. The latest behavior is to keep zero empty line if that is the case in the original input, or one empty line if the original input has more than one empty lines.

However, this behavior is NOT reflected in the documented code style on empty lines. In the documentation, it is stated that

The other exception is that it will remove any empty lines immediately following a statement that introduces a new indentation level.

This is no longer true. Consequently, the given example is also incorrect, as all the empty lines after code block open are shown to be deleted after formatting.

Describe the solution you'd like

I would like the documentation to emphasize the current code style of empty line by rewriting the "The other exception is that...new indentation level" sentence. In addition, I would like the example on the empty line code style to be as follows

# in

def foo():




    print("One new line above me will be kept!")





def bar():
    print("The original input has no new line above me; we will keep it that way.")




if condition:




    print("One new line above me will be kept!")

    print("There is a newline above me, and that's OK!")





class Point:




    x: int
    y: int

# out

# out
def foo():

    print("One new line above me will be kept!")


def bar():
    print("The original input has no new line above me; we will keep it that way.")


if condition:

    print("One new line above me will be kept!")

    print("There is a newline above me, and that's OK!")


class Point:

    x: int
    y: int

Describe alternatives you've considered

NA

Additional context

NA

Metadata

Metadata

Assignees

No one assigned

    Labels

    T: documentationImprovements to the docs (e.g. new topic, correction, etc)

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions