Skip to content

Nested f strings #4654

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

Open
shipra0803 opened this issue Apr 22, 2025 · 2 comments
Open

Nested f strings #4654

shipra0803 opened this issue Apr 22, 2025 · 2 comments
Labels
S: needs repro Needs a functional reproduction T: bug Something isn't working

Comments

@shipra0803
Copy link

Description:
While testing Black’s output, I observed that deeply nested f-strings (e.g., f"outer {f'inner {x}'}") sometimes lose indentation alignment or break unpredictably. This reduces code clarity, especially in templating or SQL query generation.

Evidence:

Input (before formatting)

query = f"SELECT {f"COUNT(*) FROM {f"users WHERE id = {user_id}"}"}"
Current output may misalign the nested f-strings.

@shipra0803 shipra0803 added the T: bug Something isn't working label Apr 22, 2025
@JelleZijlstra
Copy link
Collaborator

Can you be more precise? What is the exact behavior you're seeing and why do you think it's wrong?

@tusharsadhwani
Copy link
Collaborator

tusharsadhwani commented Apr 22, 2025

Hey! Can you also post the version of black you are using (black --version), and the formatted output produced by black that you are seeing?

@cobaltt7 cobaltt7 added the S: needs repro Needs a functional reproduction label May 25, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
S: needs repro Needs a functional reproduction T: bug Something isn't working
Projects
None yet
Development

No branches or pull requests

4 participants