Commit 91de9ea6 authored by Łukasz Langa's avatar Łukasz Langa
Browse files

Fix invalid code in an omitted trailer on large expressions

Fixes #237
parent f1f12284
Loading
Loading
Loading
Loading
+5 −1
Changes for README.md: 5 added lines, 1 removed line.
Original line number Diff line number Diff line
@@ -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

+3 −0
Changes for black.py: 3 added lines, 0 removed lines.
Original line number Diff line number Diff line
@@ -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:
+8 −0
Changes for tests/composition.py: 8 added lines, 0 removed lines.
Original line number Diff line number Diff line
@@ -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'