You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
black crashes within the reformatting code with the error message:
error: cannot format <string>: Opening paren not found in `leaves`
I reproduced this using the current head of black (black, 25.1.1.dev24+g2c135ed (compiled: no)) and on the online formatter. I can see this on both Linux and macOS and multiple versions of Python (3.12 and 3.13).
I bisected the repro, and it looks like it started breaking in #4016.
Some other things I observed:
Using other bracket groups ([] and {}) do not show this issue
The magic trailing comma in the argument is important
If the comment comes at the end, it's fine. This does not crash:
help(lambdax=(
"bar",
# comment
): False)
Expanding on the above, comments in the middle of arguments also cause the issue:
Describe the bug
Given the following code snippet:
black crashes within the reformatting code with the error message:
I reproduced this using the current head of black (
black, 25.1.1.dev24+g2c135ed (compiled: no)
) and on the online formatter. I can see this on both Linux and macOS and multiple versions of Python (3.12 and 3.13).I bisected the repro, and it looks like it started breaking in #4016.
Some other things I observed:
[]
and{}
) do not show this issueTo Reproduce
The text was updated successfully, but these errors were encountered: