Preview: Keep requiring two empty lines between module-level docstring and first function or class definition (#4028)
Fixes #4027.
This commit is contained in:
parent
9e3daa1107
commit
e808e61db8
@ -19,6 +19,8 @@
|
|||||||
indented less (#3964)
|
indented less (#3964)
|
||||||
- Multiline list and dict unpacking as the sole argument to a function is now also
|
- Multiline list and dict unpacking as the sole argument to a function is now also
|
||||||
indented less (#3992)
|
indented less (#3992)
|
||||||
|
- Keep requiring two empty lines between module-level docstring and first function or
|
||||||
|
class definition. (#4028)
|
||||||
|
|
||||||
### Configuration
|
### Configuration
|
||||||
|
|
||||||
|
@ -578,6 +578,7 @@ def maybe_empty_lines(self, current_line: Line) -> LinesBlock:
|
|||||||
and self.previous_block.previous_block is None
|
and self.previous_block.previous_block is None
|
||||||
and len(self.previous_block.original_line.leaves) == 1
|
and len(self.previous_block.original_line.leaves) == 1
|
||||||
and self.previous_block.original_line.is_triple_quoted_string
|
and self.previous_block.original_line.is_triple_quoted_string
|
||||||
|
and not (current_line.is_class or current_line.is_def)
|
||||||
):
|
):
|
||||||
before = 1
|
before = 1
|
||||||
|
|
||||||
|
11
tests/data/cases/module_docstring_followed_by_class.py
Normal file
11
tests/data/cases/module_docstring_followed_by_class.py
Normal 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
|
11
tests/data/cases/module_docstring_followed_by_function.py
Normal file
11
tests/data/cases/module_docstring_followed_by_function.py
Normal 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
|
Loading…
Reference in New Issue
Block a user