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

Visual indent changed for certain continued strings #761

Open
avancil opened this issue Jul 17, 2024 · 0 comments
Open

Visual indent changed for certain continued strings #761

avancil opened this issue Jul 17, 2024 · 0 comments

Comments

@avancil
Copy link

avancil commented Jul 17, 2024

Certain strings, wrapped with a continuation character, are getting changed with autopep8, even though pycodestyle has no issue with them, and they are PEP8 compliant.

In the code below, autopep8 wants to realign my_str. Notably:

  • This issue was NOT seen with autopep8 2.3.1 running in Python 3.10.14. It DOES show up with autopep8 2.3.1 and Python 3.12.4.
  • This issue does not show up if the f-string is not used.
  • This issue does not show up if the string is at the module level (not indented).

Python Code

def my_fn():
    """Do the thing."""
    foo = "foo"
    my_str = f"lorem ipsum lorem ipsum lorem ipsum {foo}" \
             "lorem ipsum lorem ipsum lorem ipsum"

    print(my_str)

Command Line

$ pyenv local 3.12.4
$ autopep8 --diff temp.py 
--- original/temp.py
+++ fixed/temp.py
@@ -5,6 +5,6 @@
 
 foo = "foo"
 my_str = f"lorem ipsum lorem ipsum lorem ipsum {foo}" \
-         "lorem ipsum lorem ipsum lorem ipsum"
+    "lorem ipsum lorem ipsum lorem ipsum"
 
 print(my_str)
$ pycodestyle temp.py
$ pip list | grep autopep8
autopep8                    2.3.1
$ pyenv local 3.10.14
$ autopep8 --diff temp.py 
$
$ pip list | grep autopep8
autopep8                    2.3.1

Your Environment

  • Python version: 3.12.4
  • autopep8 version: 2.3.1
  • Platform: Linux (Ubuntu 24.04)
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

1 participant