Fix invalid code in an omitted trailer on large expressions

Fixes #237
This commit is contained in:
Łukasz Langa 2018-05-21 12:29:36 -07:00
parent f1f12284e0
commit 91de9ea6e3
3 changed files with 16 additions and 1 deletions

View File

@ -654,7 +654,11 @@ More details can be found in [CONTRIBUTING](CONTRIBUTING.md).
### 18.5b1 (unreleased)
* Python grammar pickle caches are stored with the formatting caches, making
*Black* work in environments where site-packages is not user-writable (#192).
*Black* work in environments where site-packages is not user-writable (#192)
* fixed invalid code produced when standalone comments were present in a trailer
that was omitted from line splitting on a large expression (#237)
### 18.5b0

View File

@ -2606,6 +2606,9 @@ def generate_trailers_to_omit(line: Line, line_length: int) -> Iterator[Set[Leaf
if length > line_length:
break
if leaf.type == STANDALONE_COMMENT:
break
optional_brackets.discard(id(leaf))
if opening_bracket:
if leaf is opening_bracket:

View File

@ -32,6 +32,14 @@ def test(self) -> None:
# Another
):
print(i)
xxxxxxxxxxxxxxxx = Yyyy2YyyyyYyyyyy(
push_manager=context.request.resource_manager,
max_items_to_push=num_items,
batch_size=Yyyy2YyyyYyyyyYyyy.FULL_SIZE,
).push(
# Only send the first n items.
items=items[:num_items]
)
return (
"Utterly failed doctest test for %s\n"
' File "%s", line %s, in %s\n\n%s'