Commit 68c71b62 authored by Łukasz Langa's avatar Łukasz Langa
Browse files

Don't fold postscriptum standalone comment into last statement

This happened when the last statement was a simple statement.

Fixes #18
Fixes #28
parent 6c3ce53b
Loading
Loading
Loading
Loading
+5 −0
Changes for README.md: 5 added lines, 0 removed lines.
Original line number Diff line number Diff line
@@ -272,6 +272,11 @@ More details can be found in [CONTRIBUTING](CONTRIBUTING.md).
* if top level functions were separated by a comment, don't put four
  empty lines after the upper function

* fixed unstable formatting of newlines with imports

* fixed unintentional folding of post scriptum standalone comments
  into last statement if it was a simple statement (#18, #28)

* fixed missing space in numpy-style array indexing (#33)

* fixed spurious space after star-based unary expressions (#31)
+1 −1
Changes for black.py: 1 added line, 1 removed line.
Original line number Diff line number Diff line
@@ -1115,7 +1115,7 @@ def generate_comments(leaf: Leaf) -> Iterator[Leaf]:
    if content and (content[0] not in {' ', '!', '#'}):
        content = ' ' + content
    is_standalone_comment = (
        '\n' in before_comment or '\n' in content or leaf.type == token.DEDENT
        '\n' in before_comment or '\n' in content or leaf.type == token.ENDMARKER
    )
    if not is_standalone_comment:
        # simple trailing comment
+6 −0
Changes for tests/expression.py: 6 added lines, 0 removed lines.
Original line number Diff line number Diff line
@@ -124,6 +124,9 @@ async def f():
    signal.getsignal(signal.SIGINT) != signal.default_int_handler
):
    return True
last_call()
# standalone comment at ENDMARKER


# output

@@ -275,3 +278,6 @@ async def f():
    or signal.getsignal(signal.SIGINT) != signal.default_int_handler
):
    return True

last_call()
# standalone comment at ENDMARKER