Skip to content

Commit e808e61

Browse files
authored
Preview: Keep requiring two empty lines between module-level docstring and first function or class definition (#4028)
Fixes #4027.
1 parent 9e3daa1 commit e808e61

File tree

4 files changed

+25
-0
lines changed

4 files changed

+25
-0
lines changed

CHANGES.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,8 @@
1919
indented less (#3964)
2020
- Multiline list and dict unpacking as the sole argument to a function is now also
2121
indented less (#3992)
22+
- Keep requiring two empty lines between module-level docstring and first function or
23+
class definition. (#4028)
2224

2325
### Configuration
2426

src/black/lines.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -578,6 +578,7 @@ def maybe_empty_lines(self, current_line: Line) -> LinesBlock:
578578
and self.previous_block.previous_block is None
579579
and len(self.previous_block.original_line.leaves) == 1
580580
and self.previous_block.original_line.is_triple_quoted_string
581+
and not (current_line.is_class or current_line.is_def)
581582
):
582583
before = 1
583584

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
# flags: --preview
2+
"""Two blank lines between module docstring and a class."""
3+
class MyClass:
4+
pass
5+
6+
# output
7+
"""Two blank lines between module docstring and a class."""
8+
9+
10+
class MyClass:
11+
pass
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
# flags: --preview
2+
"""Two blank lines between module docstring and a function def."""
3+
def function():
4+
pass
5+
6+
# output
7+
"""Two blank lines between module docstring and a function def."""
8+
9+
10+
def function():
11+
pass

0 commit comments

Comments
 (0)