Skip to content

Commit

Permalink
For now, do not add empty line after block open.
Browse files Browse the repository at this point in the history
  • Loading branch information
yilei committed Oct 10, 2022
1 parent 3ff2710 commit 42212a3
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 7 deletions.
7 changes: 4 additions & 3 deletions src/black/lines.py
Original file line number Diff line number Diff line change
Expand Up @@ -458,7 +458,7 @@ class LinesBlock:

mode: Mode
previous_block: Optional["LinesBlock"]
is_class: bool # Whether the original line is a class def.
original_line: Line
before: int = 0
content_lines: List[str] = field(default_factory=list)
after: int = 0
Expand Down Expand Up @@ -504,7 +504,7 @@ def maybe_empty_lines(self, current_line: Line) -> LinesBlock:
block = LinesBlock(
mode=self.mode,
previous_block=self.previous_block,
is_class=current_line.is_class,
original_line=current_line,
before=before,
after=after,
)
Expand Down Expand Up @@ -630,7 +630,8 @@ def _maybe_empty_lines_for_class_or_def(
in current_line.mode
and slc is not None
and slc.previous_block is not None
and not slc.previous_block.is_class
and not slc.previous_block.original_line.is_class
and not slc.previous_block.original_line.opens_block
and slc.before <= 1
):
comment_to_add_newlines = slc
Expand Down
4 changes: 0 additions & 4 deletions tests/data/preview/comments9.py
Original file line number Diff line number Diff line change
Expand Up @@ -218,7 +218,6 @@ def decorated_with_split_leading_comments():

def main():
if a:

# Leading comment before inline function
def inline():
pass
Expand All @@ -228,14 +227,12 @@ def another_inline():
pass

else:

# More leading comments
def inline_after_else():
pass


if a:

# Leading comment before "top-level inline" function
def top_level_quote_inline():
pass
Expand All @@ -245,7 +242,6 @@ def another_top_level_quote_inline_inline():
pass

else:

# More leading comments
def top_level_quote_inline_after_else():
pass
Expand Down

0 comments on commit 42212a3

Please sign in to comment.