Describe the bug
Black throws an error trying to format files containing a parameter assignment with a generator. This is valid Python code.
error: cannot format util.py: Cannot parse: 200:43: if any(match := pattern_error.match(s) for s in buffer):
Oh no! 💥 💔 💥
1 file failed to reformat.
To Reproduce
Code sample:
if any(match := pattern_error.match(s) for s in buffer):
if match.group(2) == data_not_available:
# Error OK to ignore.
pass
Expected behavior
Black formats the file without errors. It seems to handle parameter assignment elsewhere just fine:
if not (next_line := next(buffer_iter, None)):
# Buffer is incomplete, so we return early and wait to be
# reinvoked with a complete buffer.
return status
Environment (please complete the following information):
- Version: main
- OS and Python version: Mac/Python 3.9.7
Does this bug also happen on main?
Yes
Additional context
None
Describe the bug
Black throws an error trying to format files containing a parameter assignment with a generator. This is valid Python code.
To Reproduce
Code sample:
Expected behavior
Black formats the file without errors. It seems to handle parameter assignment elsewhere just fine:
Environment (please complete the following information):
Does this bug also happen on main?
Yes
Additional context
None