Closed
Description
Describe the bug
The formatter is failing to parse single quote f-string as it cannot include a backslash inside it.
To Reproduce
- Take this test.py containing:
b = "example1"
sts = "example2"
f"\"{b}\"{' ' * (long-len(b)+1)}: \"{sts}\",\n"
- Run black without arguments.
- See error -->
File "/var/task/black/__init__.py", line 986, in assert_equivalent
dst_ast = parse_ast(dst)
File "/var/task/black/parsing.py", line 125, in parse_ast
raise SyntaxError(
f'"{b}"{\' \' * (long-len(b)+1)}: "{sts}",\n'
Expected behavior
The formatter is expected to throw the said error and fail to format the said file.
Environment (please complete the following information):
- Version: [main]
- OS and Python version: [Linux/Python 3.9.5]
Does this bug also happen on main?
Yes
Activity