[WIP] Allow a single blank line between class and function definitions #807
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Fixes #619.
However:
class
anddef
; it won't choose one over the other (nevertheless, I believe Black already does this for blank lines inside functions, so it's not totally without precedent 🙂 – in particular, both of the strict behaviours have been tried in the past (before Class new line between docstrings / vars / methods #219, one blank line was enforced; now, Black removes the blank line), and both have been determined to be suboptimal)There are several cases that weren't covered in the aforementioned issue; for example, should the following (currently rejected) be accepted? Clearly in this case it's worse than the version with no blank line, but if either class had more definitions I think it would make sense:
(which I guess would lead to something like "if the previous line is a
class
, and this line is a class/function/decorator, allow 0 or 1 leading blank lines"? should this also apply when the previous line is adef
?)tldr: I kind of feel like this is a bit of a hack when a proper solution would be more widely applicable, see #450 (comment). (at the same time, this is about the only irritation I run into on a regular basis, so I don't want to get in the way of merging this too much!)