-
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 is inconsistent with empty lines before an inner function after code block open, with or without leading comments #3300
Comments
#246 is possibly related since that's also caused by a comment before the function def. |
I agree this should be fixed. |
Looking at |
Having a look at #3035, I'd expect the newline to be removed before the first function regardless of the comment. Would you prefer otherwise? |
I would actually personally prefer the newline to be removed after a block open. I saw this is inconsistent with or without the comment, plus the current Black style says:
This is the "inner function" case. So I'm slightly in favor of changing the preview style to always remove the newline before an inner function and immediately after a block open, with or without the leading comment (I'm strong on making the behavior consistent with or without comment). I can send a separate PR to do that once we make decision. Meanwhile I updated #3302 to keep the current behavior for this case. |
I'm fully in favor of doing it, but it's fine to keep the original behavior if you'd like to 👍 I think the inner function spacing rule is secondary to the "no space in a new block" rule. |
@felix-hilden Thanks. Mind approve #3302 and get it merged to fix #246? Then I'll send a follow-up PR to for this issue. |
Done, we'll wait for another approval since Jelle's is a bit stale. Thanks! |
To Reproduce
Unformatted code:
Running
black --preview
:Expected behavior
Empty line should be consistent added (or removed) between the code block open and inner function:
Or,
Additional context
I did a bisect and this was caused by #3035.
Note that if the inner function doesn't have a leading comment, it won't remove the empty line:
Thus I believe this is an undesired behavior change in #3035?
The text was updated successfully, but these errors were encountered: