fix crash in preview mode with --line-length=1 (#4086)

This commit is contained in:
John Litborn 2023-12-05 19:19:24 +01:00 committed by GitHub
parent 3416b2c82d
commit 50d5756e8e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 11 additions and 1 deletions

View File

@ -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

View File

@ -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(

View File

@ -0,0 +1,9 @@
# flags: --preview --minimum-version=3.10 --line-length=1
def foo() -> tuple[int, int,]:
...
# output
def foo() -> tuple[
int,
int,
]: ...