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:
Charlie Marsh 2023-08-01 13:33:01 -04:00 committed by GitHub
parent 5e41f2fc7d
commit a82eb9544c
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 224 additions and 503 deletions

View file

@ -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