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

Proposal: strip empty lines between module docstring and first import #3900

Closed
euan-reid opened this issue Sep 20, 2023 · 1 comment
Closed
Labels
T: style What do we want Blackened code to look like?

Comments

@euan-reid
Copy link

euan-reid commented Sep 20, 2023

Describe the style change

Currently Black has no opinion on the number of empty lines that may exist between the module's docstring and the first import line other than collapsing down to at-most-2. I'm proposing that Black should have an opinion, specifically that there should be none (in line with the general philosophy on empty lines).

Examples in the current Black style

All three examples are left unchanged by Black 23.9.1:

"""My super cool module"""


from __future__ import annotations


def foo():
    pass
"""My super cool module"""

from __future__ import annotations


def foo():
    pass
"""My super cool module"""
from __future__ import annotations


def foo():
    pass

Desired style

"""My super cool module"
from __future__ import annotations

def foo():
    pass

Additional context

If there are no imports then Black currently enforces exactly two empty lines between the module docstring and the first line of code. If there's no docstring then Black strips all leading whitespace. I could see an argument that it should be two empty lines between the module docstring and the first import to match the former behaviour, but I think no lines fits better with the general philosophy of the Black style.

@euan-reid euan-reid added the T: style What do we want Blackened code to look like? label Sep 20, 2023
@JelleZijlstra
Copy link
Collaborator

In #3932 we instead decided to add a single newline after the docstring.

@JelleZijlstra JelleZijlstra closed this as not planned Won't fix, can't repro, duplicate, stale Oct 28, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
T: style What do we want Blackened code to look like?
Projects
None yet
Development

No branches or pull requests

2 participants