Skip to content

Commit

Permalink
fix crash in preview mode with --line-length=1 (#4086)
Browse files Browse the repository at this point in the history
  • Loading branch information
jakkdl committed Dec 5, 2023
1 parent 3416b2c commit 50d5756
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 1 deletion.
1 change: 1 addition & 0 deletions CHANGES.md
Expand Up @@ -17,6 +17,7 @@
- Standalone form feed characters at the module level are no longer removed (#4021)
- Additional cases of immediately nested tuples, lists, and dictionaries are now
indented less (#4012)
- Fix crash in preview mode when using a short `--line-length` (#4086)

### Configuration

Expand Down
2 changes: 1 addition & 1 deletion src/black/linegen.py
Expand Up @@ -744,7 +744,7 @@ def left_hand_split(
if leaf.type in OPENING_BRACKETS:
matching_bracket = leaf
current_leaves = body_leaves
if not matching_bracket:
if not matching_bracket or not tail_leaves:
raise CannotSplit("No brackets found")

head = bracket_split_build_line(
Expand Down
@@ -0,0 +1,9 @@
# flags: --preview --minimum-version=3.10 --line-length=1

def foo() -> tuple[int, int,]:
...
# output
def foo() -> tuple[
int,
int,
]: ...

0 comments on commit 50d5756

Please sign in to comment.