Implement Black's rules around newlines before and after class docstrings (#6209)
## Summary Black allows up to one blank line _before_ a class docstring, and enforces one blank line _after_ a class docstring. This PR implements that handling. The cases in `crates/ruff_python_formatter/resources/test/fixtures/ruff/statement/class_definition.py` match Black identically.
This commit is contained in:
@@ -43,3 +43,52 @@ class TestTrailingComment2: # trailing comment
|
||||
pass
|
||||
|
||||
|
||||
class Test:
|
||||
"""Docstring"""
|
||||
|
||||
|
||||
class Test:
|
||||
# comment
|
||||
"""Docstring"""
|
||||
|
||||
|
||||
class Test:
|
||||
"""Docstring"""
|
||||
x = 1
|
||||
|
||||
|
||||
class Test:
|
||||
"""Docstring"""
|
||||
# comment
|
||||
x = 1
|
||||
|
||||
|
||||
class Test:
|
||||
|
||||
"""Docstring"""
|
||||
|
||||
|
||||
class Test:
|
||||
# comment
|
||||
|
||||
"""Docstring"""
|
||||
|
||||
|
||||
class Test:
|
||||
|
||||
# comment
|
||||
|
||||
"""Docstring"""
|
||||
|
||||
|
||||
class Test:
|
||||
|
||||
"""Docstring"""
|
||||
x = 1
|
||||
|
||||
|
||||
class Test:
|
||||
|
||||
"""Docstring"""
|
||||
# comment
|
||||
x = 1
|
||||
|
||||
Reference in New Issue
Block a user