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 v24.4.1 & v24.4.2 fails to format f-strings containing multi-line strings #4362

Closed
gbatagian opened this issue May 14, 2024 · 4 comments
Labels
T: bug Something isn't working

Comments

@gbatagian
Copy link

Black versions 24.4.1 and 24.4.2 encounter an issue when formatting Python code containing an f-string that includes a multi-line string. Example:

s = f"""{'''a
            b
            c'''}"""

print(s)

this is valid python syntax, as it is executable, but black cannot format it, as indicated below:

>>> cat black_sample.py 
s = f"""{'''a
            b
            c'''}"""

print(s)

>>> python --version
Python 3.12.1

>>> python black_sample.py 
a
            b
            c

>>> black --version
black, 24.4.2 (compiled: yes)
Python (CPython) 3.12.1

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

Oh no! 💥 💔 💥
1 file failed to reformat.
@gbatagian gbatagian added the T: bug Something isn't working label May 14, 2024
@hauntsaninja
Copy link
Collaborator

I think this was fixed by #4339 , we should cut a release with it soon

@peku33
Copy link

peku33 commented Jul 31, 2024

Hi, any chance this is going to be released soon? Latest version available since april seems to have this issue.

@JelleZijlstra
Copy link
Collaborator

Yeah I should cut a release soon. Maybe tonight.

@peku33
Copy link

peku33 commented Jul 31, 2024

Many thanks, @JelleZijlstra, fingers crossed 🤞

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