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

Black introduces E302 with a Comment at Line 0 and no Imports #40

Closed
sethmlarson opened this issue Mar 18, 2018 · 8 comments
Closed

Black introduces E302 with a Comment at Line 0 and no Imports #40

sethmlarson opened this issue Mar 18, 2018 · 8 comments
Labels
F: comments The syntactic kind. Not in the language grammar, always on our minds. Best bugs. T: bug Something isn't working

Comments

@sethmlarson
Copy link
Member

sethmlarson commented Mar 18, 2018

Operating system: Debian 9
Python version: 3.6.4
Black version: black.py, version 18.3a2

Black converts this:

# License/Header comment

def includeme(config):
    pass

into this:

# License/Header comment
def includeme(config):
    pass

which causes this:

./compute/storage/__init__.py:14:1: E302 expected 2 blank lines, found 0
@ambv
Copy link
Collaborator

ambv commented Mar 18, 2018

Thanks for your report, I will be dealing with empty lines for the next release!

@ambv ambv added T: bug Something isn't working F: comments The syntactic kind. Not in the language grammar, always on our minds. Best bugs. labels Mar 18, 2018
@sethmlarson
Copy link
Member Author

Thanks for the quick turn-around! Do you have a donation link?

@ambv
Copy link
Collaborator

ambv commented Mar 18, 2018

Thanks for asking! I appreciate that. I don't intend to make money by working on Black.

I invite you to donate to the Python Software Foundation instead. This organization protects our trademarks, sponsors development sprints and conferences, and so on.

@sethmlarson
Copy link
Member Author

Oh I'm already a donor to PSF. I'll have to increase my donation! :)

@ambv
Copy link
Collaborator

ambv commented Mar 21, 2018

This is now fixed in 18.3a3! Thanks! ✨ 🍰 ✨

@ambv ambv closed this as completed Mar 21, 2018
@nickpresta
Copy link

nickpresta commented Apr 8, 2019

I'm not sure if this is a regression, or if classes are handled differently, but I have the following code:

newline here
newline here
# -----
# something
# -----
class FooState:
    YES = "yes"
    NO = "no"

which black reformats to:

no newlines at all
# -----
# something
# -----
class FooState:
    YES = "yes"
    NO = "no"

which results in:

E302 expected 2 blank lines, found 0

Should I open a new issue? Is this expected behavior and flake8 is just wrong?

@ambv
Copy link
Collaborator

ambv commented Apr 8, 2019

flake8 is wrong, you don't have to have those pointless empty new lines at the start of the file.

@nickpresta
Copy link

nickpresta commented Apr 8, 2019

I figured as much. I disabled E302 given I want to let black handle all "formatting"-related concerns. Thanks for the quick reply!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
F: comments The syntactic kind. Not in the language grammar, always on our minds. Best bugs. T: bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants