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

Combine f-strings which would be placed on the same line #4389

Open
pushfoo opened this issue Jun 26, 2024 · 0 comments
Open

Combine f-strings which would be placed on the same line #4389

pushfoo opened this issue Jun 26, 2024 · 0 comments
Labels
T: style What do we want Blackened code to look like?

Comments

@pushfoo
Copy link

pushfoo commented Jun 26, 2024

Describe the style change

Combine short f-string segements which would be placed on the same line

Examples in the current Black style

  1. Input: use a multi-part f-string shorter than line length
    sep= " "
    FSTRING = (
        f"many"
        f"{sep}"
        f"tiny"
        f"{sep}"
        f"fstrings"
    )
  2. Run it locally or via this vercel example
  3. The output wastes horizontal space: it puts them on one line, but not joined together
    sep= " "
    FSTRING = f"many" f"{sep}" f"tiny" f"{sep}" f"fstrings"

Desired style

sep = " "
FSTRING = f"many{sep}tiny{sep}fstrings"

Additional context
Originally found while reviewing a PR for Python Arcade, a game framework and educational tool.

@pushfoo pushfoo added the T: style What do we want Blackened code to look like? label Jun 26, 2024
@pushfoo pushfoo changed the title Join f-string components which would be placed on the same line Combine f-strings which would be placed on the same line Jun 26, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
T: style What do we want Blackened code to look like?
Projects
None yet
Development

No branches or pull requests

1 participant