Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Insert two empty lines after top level suite with trailing def/class #7947

Closed
konstin opened this issue Oct 13, 2023 · 1 comment
Closed
Labels
bug Something isn't working formatter Related to the formatter

Comments

@konstin
Copy link
Member

konstin commented Oct 13, 2023

Black formats

if True:

    def double(s):
        return s + s
print("out")

as

if True:

    def double(s):
        return s + s


print("out")

while we format it as

if True:

    def double(s):
        return s + s

print("out")

Black does so because on the top level, there are two newlines after a function or class definition. We currently don't see that the if statement is on the top level when formatting its suite, so we can't that we need one more newline here. This is a follow-up to #7946.

@konstin konstin added bug Something isn't working formatter Related to the formatter labels Oct 13, 2023
@MichaReiser MichaReiser added this to the Formatter: Stable milestone Oct 16, 2023
@konstin
Copy link
Member Author

konstin commented Nov 14, 2023

Works on main

@konstin konstin closed this as completed Nov 14, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working formatter Related to the formatter
Projects
None yet
Development

No branches or pull requests

2 participants