Skip to content

Commit

Permalink
Fix a bug where empty line is added before eof.
Browse files Browse the repository at this point in the history
  • Loading branch information
yilei committed Sep 30, 2022
1 parent e0c1580 commit ab0895c
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 0 deletions.
2 changes: 2 additions & 0 deletions src/black/__init__.py
Expand Up @@ -1085,6 +1085,8 @@ def _format_str_once(src_contents: str, *, mode: Mode) -> str:
current_line, mode=mode, features=split_line_features
):
block.content_lines.append(str(line))
if dst_blocks:
dst_blocks[-1].after = 0
dst_contents = []
for block in dst_blocks:
dst_contents.extend(block.all_lines())
Expand Down
@@ -0,0 +1,4 @@
# Make sure when the file ends with class's docstring,
# It doesn't add extra blank lines.
class ClassWithDocstring:
"""A docstring."""

0 comments on commit ab0895c

Please sign in to comment.