Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions CHANGES.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
1 change: 1 addition & 0 deletions src/black/lines.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
11 changes: 11 additions & 0 deletions tests/data/cases/module_docstring_followed_by_class.py
Original file line number Diff line number Diff line change
@@ -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 changes: 11 additions & 0 deletions tests/data/cases/module_docstring_followed_by_function.py
Original file line number Diff line number Diff line change
@@ -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