-
Notifications
You must be signed in to change notification settings - Fork 2.7k
Closed
Labels
T: bugSomething isn't workingSomething isn't working
Description
Describe the bug
The following code can not be parsed/formatted by black:
with {} as name_3, (name_2 := name_4):
def name_3[**name_1]():
passblack reported the following error:
> black -l 100 -C bug.py
error: cannot format bug.py: Cannot parse: 1:26: with {} as name_3, name_2 := name_4:
Oh no! 💥 💔 💥
1 file failed to reformat.
but it can be parsed by cpython:
from ast import parse
parse(
'with {} as name_3, (name_2 := name_4):\n'
'\n'
' def name_3[**name_1]():\n'
' pass\n'
)result:
returncode: 0
Environment
- Black's version: current main (dbb14ea)
- OS and Python version: Linux/Python 3.12.6 (main, Sep 9 2024, 22:11:19) [Clang 18.1.8 ]
Additional context
The bug was found by pysource-codegen (see #3908)
The issue description above was created by a script. Let me know if you think it can be improved.
One think I noted is that the following code causes also a formatting failure:
with a, (name_2 := name_4):
passBut pysource-minimize did not found this minimal example for some reason.
Metadata
Metadata
Assignees
Labels
T: bugSomething isn't workingSomething isn't working