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

Two blank lines after an import should be reduced to one #2020

Open
WhyNotHugo opened this issue Mar 5, 2021 · 5 comments
Open

Two blank lines after an import should be reduced to one #2020

WhyNotHugo opened this issue Mar 5, 2021 · 5 comments
Labels
F: empty lines Wasting vertical space efficiently. S: accepted The changes in this design / enhancement issue have been accepted and can be implemented T: style What do we want Blackened code to look like?

Comments

@WhyNotHugo
Copy link
Contributor

Describe the style change

This applies to the first line of code after the block of imports at the top of the file.

These lines are not changed by black:

from middleman.authentication import validate_oauth_token

logger = logging.getLogger(__name__)

This is changed to the above (makes sense to me):

from middleman.authentication import validate_oauth_token
logger = logging.getLogger(__name__)

However, black does not reformat this:

from middleman.authentication import validate_oauth_token


logger = logging.getLogger(__name__)

This is very annoying since it allows for inconsistency.

Desired style

I think black should reformat that final example to look like the first. As an alternative, it could also always leave two lines. Either one or two lines is fine by me, but only one option should be valid.

Additional context

I think it's that simple.

@WhyNotHugo WhyNotHugo added the T: style What do we want Blackened code to look like? label Mar 5, 2021
@ichard26
Copy link
Collaborator

ichard26 commented Mar 5, 2021

I'm sure I've seen a design issue talking about this, but I can't seem to find it...

Maybe the issue doesn't actually exist and I'm just acting crazy :)

@ichard26
Copy link
Collaborator

ichard26 commented Mar 5, 2021

Also, can't reproduce on the Black Playground.

@ichard26 ichard26 added the F: empty lines Wasting vertical space efficiently. label May 29, 2021
@JelleZijlstra
Copy link
Collaborator

Can't find any duplicates in F: empty lines Wasting vertical space efficiently. . The bug is really that the last example (with two lines after the import) doesn't get reduced to one line, and I can reproduce that on main.

@felix-hilden
Copy link
Collaborator

The two-line issue still persists: playground

@JelleZijlstra JelleZijlstra changed the title First line after imports is not formatted consistently Two blank lines after an import should be reduced to one Apr 29, 2023
@JelleZijlstra JelleZijlstra added the S: accepted The changes in this design / enhancement issue have been accepted and can be implemented label Apr 29, 2023
kastkeepitjumpinlikekangaroos added a commit to kastkeepitjumpinlikekangaroos/black that referenced this issue Oct 16, 2024
kastkeepitjumpinlikekangaroos added a commit to kastkeepitjumpinlikekangaroos/black that referenced this issue Oct 16, 2024
@kastkeepitjumpinlikekangaroos

hey! I opened a PR here trying to address this issue #4489 - I made some test cases from the examples in the issue description which are working as described

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
F: empty lines Wasting vertical space efficiently. S: accepted The changes in this design / enhancement issue have been accepted and can be implemented T: style What do we want Blackened code to look like?
Projects
None yet
Development

No branches or pull requests

5 participants