Describe the bug Black cannot format code that uses the walrus operator, := , in parentheses
To Reproduce Steps to reproduce the behavior:
if (blah := 4):
print(666)
error: cannot format example.py: cannot use --safe with this file; failed to parse source file. AST error message: invalid syntax (<unknown>, line 1)
Expected behavior It should format the file and not throw an error
Environment (please complete the following information):
Does this bug also happen on master? No
I can't repro this either locally or on https://black.now.sh so there's something likely with your environment. I would check what version of python Black is running with. You'd get this message if you're running it with something <3.8
I can't reproduce this either. Tested with black 19.10b0 on Mint 19 and Python 3.8.1
✗ cat 1262.py
if (blah := 4):
print(666)
✗ black .
reformatted 1262.py
All done! ✨ 🍰 ✨
1 file reformatted, 17 files left unchanged.
✗ cat 1262.py
if (blah := 4) :
print(666)
Most helpful comment
I can't repro this either locally or on https://black.now.sh so there's something likely with your environment. I would check what version of python Black is running with. You'd get this message if you're running it with something <3.8