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

[WIP] Allow a single blank line between class and function definitions #807

Closed
wants to merge 1 commit into from

Conversation

sersorrel
Copy link
Contributor

Fixes #619.

However:

  • it "fixes" it by allowing up to one blank line between class and def; 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)
  • one test is currently failing due to the above
  • there are no new tests specifically for this behaviour (is there documentation on how to write a test, or do I have to copy-paste an existing one?)
  • I don't know if the way I've implemented this is actually sensible

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:

class C:

    class Inner:
        pass

(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 a def?)

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!)

@cooperlees
Copy link
Collaborator

This PR has become very stale. Please reopen if you wish to finish it.

@cooperlees cooperlees closed this Aug 27, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

One space between class definition and the first inner method
2 participants