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

black 24.4.0 returns error when parsing valid Python fstring sentence #4314

Closed
semuadmin opened this issue Apr 18, 2024 · 1 comment
Closed
Labels
T: bug Something isn't working

Comments

@semuadmin
Copy link

Describe the bug

black fails to parse or reformat the following valid Python sentence:

   print(f"PRN {sat["PRN"]}: {sat["DF398"]}")

To Reproduce

Execute black against this code snippet:

sat = {}
sat["PRN"] = 32
sat["DF398"] = 0.1648652
print(f"PRN {sat["PRN"]}: {sat["DF398"]}")
$ black temp.py --target-version py39

The resulting error (with all target versions from py39 to py312) is:

error: cannot format temp.py: Cannot parse: 4:18: print(f"PRN {sat["PRN"]}: {sat["DF398"]}")

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

Expected behavior

black should successfully parse the sentence and (if necessary) reformat it

Environment

MacOS 14.4.1 (Sonoma), but same behaviour on Ubuntu 22.04 and Windows 11 on all versions of Python >=3.11.

black, 24.4.0 (compiled: yes)
Python (CPython) 3.12.3

Additional context

@semuadmin semuadmin added the T: bug Something isn't working label Apr 18, 2024
@semuadmin
Copy link
Author

my bad - as you were

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

1 participant