black icon indicating copy to clipboard operation
black copied to clipboard

string_processing: Error when re-flowing implicitly concatenated r-strings

Open Feuermurmel opened this issue 2 years ago • 0 comments

Describe the bug

Trying to format the following input (playground) with black -l 1 --preview leads to an error:

dict(a=r' ' r'')
$ black -l 1 --preview foo.py 
error: cannot format foo.py: Cannot parse: 5:4:     r""

Oh no! 💥 💔 💥
1 file failed to reformat.

Some additional variants that lead to the same error:

dict(a=r' ' '')
dict(a=r' ' " ")

The error does not appear if --preview is not used. The file is formatted correctly in that case.

Environment

  • Black's version: 23.7.0 (compiled: yes)
  • OS and Python version: Python 3.8.18 on macOS 12.6.8 (Apple Silicon)

Also fails in the playground using the current main version (see above).

Feuermurmel avatar Aug 27 '23 10:08 Feuermurmel