Describe the bug
black hangs (or takes an extremely long time?) to process a file with a multiline f-string containing a bunch of escaped quotation marks.
To Reproduce
Run black against this file:
def testing():
somevar = "some value"
return f"""
{somevar} the following line causes the issue:
\" \" \" \" \" \" \" \" \" \" \" \" \" \" \" \" \" \" \" \" \" \" \" \" \" \" \" \" \" \" \" \" \" \" \" \" \" \" \" \" \" \" \" \" \" \" \" \" \" \" \" \"
"""
Will just hang without any output.
Expected behavior
Should run to completion within at most 1 second.
Environment
- Black's version: 24.10.0 (was working with 24.4.2, probably introduced in 24.8.0)
- OS and Python version: macOS/Python 3.13.0
Additional context
Extracting the quotes into a variable seems to circumvent the issue:
def testing():
somevar = "some value"
quotes = """\" \" \" \" \" \" \" \" \" \" \" \" \" \" \" \" \" \" \" \" \" \" \" \" \" \" \" \" \" \" \" \" \" \" \" \" \" \" \" \" \" \" \" \" \" \" \" \" \" \" \" \""""
return f"""
{somevar} the following line causes the issue:
{quotes}
"""
Describe the bug
black hangs (or takes an extremely long time?) to process a file with a multiline f-string containing a bunch of escaped quotation marks.
To Reproduce
Run black against this file:
Will just hang without any output.
Expected behavior
Should run to completion within at most 1 second.
Environment
Additional context
Extracting the quotes into a variable seems to circumvent the issue: