-
Notifications
You must be signed in to change notification settings - Fork 1.8k
Closed
Labels
bugSomething isn't workingSomething isn't workingformatterRelated to the formatterRelated to the formatter
Milestone
Description
ruff format generally adds two blank lines between a class and a previous commented line.
But it does not if the class is the first line of code of the file.
Not a bug and only a minor inconsistency, but also black does always add two blank lines, so just documenting the behavior here.
Reproducible example
Consider following file ruff_inconsistency.py:
# a = 1 # uncomment to change behavior
# comment
class A:
def foo(self):
pass
# comment
class B:
def bar(self):
passwill format into:
# a = 1 # uncomment to change behavior
# comment
class A:
def foo(self):
pass
# comment
class B:
def bar(self):
passWe can see a single blank line before class A: but two blank lines before class B:.
As a note, black does not exhibit that behavior, and consistently add two blank lines:
$ diff <(black -q - < ruff_inconsistency.py) <(ruff format -q - < ruff_inconsistency.py)
5d4
<Versions
$ ruff --version
ruff 0.1.2
$ black --version
black, 23.10.0 (compiled: no)
Python (CPython) 3.12.0Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
bugSomething isn't workingSomething isn't workingformatterRelated to the formatterRelated to the formatter