-
Notifications
You must be signed in to change notification settings - Fork 2.5k
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 doesn't enforce two empty lines before functions on module level when they have a sticky leading comment #246
Comments
Judging by the comments in comments5.py it's not trivial to support this case with the current implementation. @ambv, would the |
@Sterbic, yes. The way that would work is to modify @hugovk, as a workaround in the mean time, add the extra newline yourself, Black will keep it (as you found out in test2.py). |
Interesting, with give it a shot if I find some free time next week. |
I was just going to post the same issue! Confirmed on my end too
leads to |
Can confirm that this is still an issue on main. Also even this code is untouched which isn't great: all_data = []
all_versions = set()
# Comment
def thing():
pass |
black 23.1.0 introduces a new style that disagrees with flake8 in nested functions: Enforce empty lines before classes and functions with sticky leading comments In this case we can get rid of the simple comment to make both of them happy. See the release note[0] and related issue[1] [0] https://github.com/psf/black/releases/tag/23.1.0 [1] psf/black#246 Signed-off-by: Mert Kırpıcı <[email protected]>
black 23.1.0 introduces a new style that disagrees with flake8 in nested functions: Enforce empty lines before classes and functions with sticky leading comments In this case we can get rid of the simple comment to make both of them happy. See the release note[0] and related issue[1] [0] https://github.com/psf/black/releases/tag/23.1.0 [1] psf/black#246 Signed-off-by: Mert Kırpıcı <[email protected]>
Operating system: macOS High Sierra
Python version: 3.6.5
Black version: 18.5b0
pycodestyle version: 2.4.0
Does also happen on master: yes
Should Black insert a newline between these variables and the function?
pycodestyle complains about test.py but Black doesn't change it
$ cat test.py
Both pycodestyle and Black are fine with test2.py
$ cat test2.py
Black reformats test3.py, with no comment
$ cat test3.py
The text was updated successfully, but these errors were encountered: