Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGES.md
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# flags: --preview --minimum-version=3.10 --line-length=1

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