Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

f-string with internal same-quote expression #4138

Closed
quittle opened this issue Dec 31, 2023 · 1 comment
Closed

f-string with internal same-quote expression #4138

quittle opened this issue Dec 31, 2023 · 1 comment
Labels
T: bug Something isn't working

Comments

@quittle
Copy link

quittle commented Dec 31, 2023

Verified with https://black.vercel.app/?version=main

Describe the bug

Black fails to parse format strings (f-strings) where an express

To Reproduce

Default black settings with either of these

f"{""}"

Error

cannot use --safe with this file; failed to parse source file AST: f-string: expecting '}' (, line 1)
This could be caused by running Black with an older Python version that does not support new syntax used in your source file.

f"{'"'}"

Error

Cannot parse: 1:5: f"{'"'}"

f'''{'''"""'''}'''

Error

Cannot parse: 1:8: EOF in multi-line string

Expected behavior

The code can be parsed successfully, just as Python 3.10, 3.11, and 3.12 can successfully evaluate the code.

Environment

  • Black's version: main and 23.10.1
  • OS and Python version: Python 3.10, 3.11, and 3.12 on Ubuntu 22.04.2 in WSL

Additional context

Using f"""{""}""" works fine so long as the triple quotes aren't present internally.

@quittle quittle added the T: bug Something isn't working label Dec 31, 2023
@hauntsaninja
Copy link
Collaborator

hauntsaninja commented Dec 31, 2023

Thanks, duplicate of #3746

(And note that Python 3.11 and lower cannot evaluate this code)

@hauntsaninja hauntsaninja closed this as not planned Won't fix, can't repro, duplicate, stale Dec 31, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
T: bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants