From be46470e55224c01d65bf6ac09e5e991afc099ad Mon Sep 17 00:00:00 2001 From: Jelle Zijlstra Date: Sat, 9 Dec 2023 19:37:47 -0800 Subject: [PATCH] Fix up merge --- src/black/lines.py | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/src/black/lines.py b/src/black/lines.py index bd86390..02bd8e2 100644 --- a/src/black/lines.py +++ b/src/black/lines.py @@ -681,14 +681,17 @@ def _maybe_empty_lines(self, current_line: Line) -> Tuple[int, int]: # In preview mode, always allow blank lines, except right before a function # docstring - is_empty_first_line_ok = ( - not is_docstring(current_line.leaves[0]) - or ( - self.previous_line - and self.previous_line.leaves[0] - and self.previous_line.leaves[0].parent - and not is_funcdef(self.previous_line.leaves[0].parent) - ) + is_empty_first_line_ok = not is_docstring(current_line.leaves[0]) or ( + self.previous_line + and self.previous_line.leaves[0] + and self.previous_line.leaves[0].parent + and not is_funcdef(self.previous_line.leaves[0].parent) + ) + + if ( + self.previous_line + and self.previous_line.opens_block + and not is_empty_first_line_ok ): return 0, 0 return before, 0