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

Formatting text with variables using f"" lead to not nice break #765

Open
Hadatko opened this issue Aug 9, 2024 · 3 comments
Open

Formatting text with variables using f"" lead to not nice break #765

Hadatko opened this issue Aug 9, 2024 · 3 comments

Comments

@Hadatko
Copy link

Hadatko commented Aug 9, 2024


Python Code

print(f"{dasdsadasdsadassdsadasdasddasddasd}{dasdsadasdsadasdasddasd}{dasdsadasdsadasdasddasd}")

This lead to

print(f"{dasdsadasdsadassdsadasdasddasddasd}{
dasdsadasdsadasdasddasd}{dasdsadasdsadasdasddasd}")

Better would be

print(f"{dasdsadasdsadassdsadasdasddasddasd}\
{dasdsadasdsadasdasddasd}{dasdsadasdsadasdasddasd}")

or format it as without "f" (like basic string without variables)

Command Line and Configuration

.pep8, setup.cfg, ...

[pep8]

VSCode default

Command Line

$ autopep8 

VSCode default

Your Environment

  • Python version:
  • autopep8 version:
  • Platform: windows, linux, macOSX, and other OS...
@endolith
Copy link

endolith commented Sep 4, 2024

This produces errors like

SyntaxError: unterminated string literal (detected at line 60)

Your example could also be broken into multiple lines like

print(f"{dasdsadasdsadassdsadasdasddasddasd}"
      f"{dasdsadasdsadasdasddasd}"
      f"{dasdsadasdsadasdasddasd}")

@aconchillo
Copy link

aconchillo commented Sep 19, 2024

I have also found this issue. Breaking a formatted string like this also causes issue in the output.

@cjcdev
Copy link

cjcdev commented Sep 28, 2024

Same issue with python 3.12.3, autopep8==2.3.1

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants