Skip to content

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

@Feuermurmel

Description

@Feuermurmel

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).

Metadata

Metadata

Assignees

No one assigned

    Labels

    C: preview styleIssues with the preview and unstable style. Add the name of the responsible feature in the title.F: stringsRelated to our handling of stringsT: bugSomething isn't working

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions