Skip to content
This repository was archived by the owner on Jul 11, 2022. It is now read-only.

Commit 68c71b6

Browse files
committed
Don't fold postscriptum standalone comment into last statement
This happened when the last statement was a simple statement. Fixes pytest-dev#18 Fixes pytest-dev#28
1 parent 6c3ce53 commit 68c71b6

File tree

3 files changed

+12
-1
lines changed

3 files changed

+12
-1
lines changed

README.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -272,6 +272,11 @@ More details can be found in [CONTRIBUTING](CONTRIBUTING.md).
272272
* if top level functions were separated by a comment, don't put four
273273
empty lines after the upper function
274274

275+
* fixed unstable formatting of newlines with imports
276+
277+
* fixed unintentional folding of post scriptum standalone comments
278+
into last statement if it was a simple statement (#18, #28)
279+
275280
* fixed missing space in numpy-style array indexing (#33)
276281

277282
* fixed spurious space after star-based unary expressions (#31)

black.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1115,7 +1115,7 @@ def generate_comments(leaf: Leaf) -> Iterator[Leaf]:
11151115
if content and (content[0] not in {' ', '!', '#'}):
11161116
content = ' ' + content
11171117
is_standalone_comment = (
1118-
'\n' in before_comment or '\n' in content or leaf.type == token.DEDENT
1118+
'\n' in before_comment or '\n' in content or leaf.type == token.ENDMARKER
11191119
)
11201120
if not is_standalone_comment:
11211121
# simple trailing comment

tests/expression.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -124,6 +124,9 @@ async def f():
124124
signal.getsignal(signal.SIGINT) != signal.default_int_handler
125125
):
126126
return True
127+
last_call()
128+
# standalone comment at ENDMARKER
129+
127130

128131
# output
129132

@@ -275,3 +278,6 @@ async def f():
275278
or signal.getsignal(signal.SIGINT) != signal.default_int_handler
276279
):
277280
return True
281+
282+
last_call()
283+
# standalone comment at ENDMARKER

0 commit comments

Comments
 (0)