Open
Description
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)
Metadata
Metadata
Assignees
Labels
No labels
Activity