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 fails to format triple quoted string with a new line in f-string. #4375

Closed
apes0 opened this issue Jun 4, 2024 · 4 comments
Closed
Labels
T: bug Something isn't working

Comments

@apes0
Copy link

apes0 commented Jun 4, 2024

Describe the bug

Black fails to format an f-string, containing a triple quoted string, that has a new line in it.

To Reproduce

For example, take this code:

a = f'''{"""
"""}'''

And run it with these arguments:

$ black file.py

The resulting error is:

error: cannot format a.py: Cannot parse: 1:9: a = f'''{"""

Expected behavior

The file should be formatted. I am not sure how this should get formatted though. The code is valid for both versions of python that i tested.

Environment

  • Black's version: 24.4.2
  • OS and Python version: Ubuntu 24.04 and Python 3.12/3.10 (fails on both)

P.S.: This seems somewhat similar to #4350?

@apes0 apes0 added the T: bug Something isn't working label Jun 4, 2024
@vetedde
Copy link

vetedde commented Jun 29, 2024

Is problem actual?
image

@apes0
Copy link
Author

apes0 commented Jun 30, 2024

Hmm...
Still throws an error for me.

python 3.10:
image

python 3.12:
image

Which version of black are you using?

@tusharsadhwani
Copy link
Contributor

This is fixed on main, but hasn't been released yet.

@hauntsaninja
Copy link
Collaborator

Fixed by #4339

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

4 participants