Preview: Keep requiring two empty lines between module-level docstring and first function or class definition (#4028)

Fixes #4027.
This commit is contained in:
Yilei Yang 2023-11-06 14:30:04 -08:00 committed by GitHub
parent 9e3daa1107
commit e808e61db8
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 25 additions and 0 deletions

View File

@ -19,6 +19,8 @@
indented less (#3964)
- Multiline list and dict unpacking as the sole argument to a function is now also
indented less (#3992)
- Keep requiring two empty lines between module-level docstring and first function or
class definition. (#4028)
### Configuration

View File

@ -578,6 +578,7 @@ def maybe_empty_lines(self, current_line: Line) -> LinesBlock:
and self.previous_block.previous_block is None
and len(self.previous_block.original_line.leaves) == 1
and self.previous_block.original_line.is_triple_quoted_string
and not (current_line.is_class or current_line.is_def)
):
before = 1

View File

@ -0,0 +1,11 @@
# flags: --preview
"""Two blank lines between module docstring and a class."""
class MyClass:
pass
# output
"""Two blank lines between module docstring and a class."""
class MyClass:
pass

View File

@ -0,0 +1,11 @@
# flags: --preview
"""Two blank lines between module docstring and a function def."""
def function():
pass
# output
"""Two blank lines between module docstring and a function def."""
def function():
pass