Skip to content

Commit 88e7833

Browse files
worksbyfridayclaudecobaltt7
authored
Fix crash on standalone comment in lambda default arguments (#4993)
Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com> Co-authored-by: cobalt <61329810+cobaltt7@users.noreply.github.com>
1 parent ff094ac commit 88e7833

File tree

3 files changed

+29
-1
lines changed

3 files changed

+29
-1
lines changed

CHANGES.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
<!-- Changes that affect Black's stable style -->
1515

1616
- Don't double-decode input, causing non-UTF-8 files to be corrupted (#4964)
17+
- Fix crash on standalone comment in lambda default arguments (#4993)
1718

1819
### Preview style
1920

src/black/nodes.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -689,7 +689,7 @@ def is_one_sequence_between(
689689
break
690690

691691
else:
692-
raise LookupError("Opening paren not found in `leaves`")
692+
return False
693693

694694
commas = 0
695695
_opening_index += 1
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
help(lambda x=(
2+
# comment
3+
"bar",
4+
): False)
5+
6+
result = (lambda x=(
7+
# a standalone comment
8+
1,
9+
2,
10+
3,
11+
): x)
12+
13+
# output
14+
15+
help(
16+
lambda x=(
17+
# comment
18+
"bar",
19+
): False,
20+
)
21+
22+
result = lambda x=(
23+
# a standalone comment
24+
1,
25+
2,
26+
3,
27+
): x

0 commit comments

Comments
 (0)