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 formatter may change the content of string in nested f-strings #4216

Closed
koitococo opened this issue Feb 7, 2024 · 1 comment
Closed
Labels
T: bug Something isn't working

Comments

@koitococo
Copy link

Describe the bug

In Python 3.12, black formatter may change the content of string in nested f-strings

To Reproduce

For example, take this code:

def test(parts: list[str]):
    print(f"{"-".join(parts)}")

And run it with these arguments:

$ black test.py --target-version=py312 

The resulting error is:

contents changed to:

def test(parts: list[str]):
    print(f"{" - ".join(parts)}")

Expected behavior

contents of string should NOT change

Environment

  • Black's version: 24.1.1 (compiled: yes)
  • OS and Python version: [Fedora release 39/Python 3.12.1]

Additional context

@koitococo koitococo added the T: bug Something isn't working label Feb 7, 2024
@hauntsaninja
Copy link
Collaborator

Duplicate of #3746 (if you use Black's default settings, you get an error on this example, Black doesn't currently support PEP 701 at all)

@hauntsaninja hauntsaninja closed this as not planned Won't fix, can't repro, duplicate, stale Feb 7, 2024
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