forked from DonJayamanne/pythonVSCode
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
autopep8 formatOnSave breaks f-strings on long lines, causing "unterminated string literal" or "EOL while scanning string literal" #22644
Labels
info-needed
Issue requires more information from poster
triage-needed
Needs assignment to the proper sub-team
Comments
github-actions
bot
added
the
triage-needed
Needs assignment to the proper sub-team
label
Dec 13, 2023
Can you test this by:
This seems like |
github-actions
bot
added
the
info-needed
Issue requires more information from poster
label
Dec 13, 2023
You're correct, I didn't know about that issue. Please disregard my report. |
github-actions
bot
removed
the
info-needed
Issue requires more information from poster
label
Dec 13, 2023
Actually, strike that... The file was already formatted in vscode when I tested directly with autopep8... Sorry for the confusion. It seems like autopep8 doesn't break the line at all: $ cat test.py
mystr = 'abc'
path = f'aVeryLargeFStringLineThatBreak{mystr}aVeryLargeFStringLineThatBreaksWithaPep8'
$ cat test.py | python3 -m autopep8 -
mystr = 'abc'
path = f'aVeryLargeFStringLineThatBreak{mystr}aVeryLargeFStringLineThatBreaksWithaPep8' $ cat test2.py
mystr = 'abc'
path = f'aVeryLargeFStringLineThatBreak{mystr}aVeryLargeFStringLineThatBreaksWithaPep8'
long_breakable_line = 'str' + 'str' + 'str' + 'str' + 'str' + 'str' + 'str' + 'str' + 'str' + 'str' + 'str' + 'str' + 'str' + 'str' + 'str' + 'str' + 'str' + 'str' + 'str' + 'str'
$ cat test2.py | python3 -m autopep8 -
mystr = 'abc'
path = f'aVeryLargeFStringLineThatBreak{mystr}aVeryLargeFStringLineThatBreaksWithaPep8'
long_breakable_line = 'str' + 'str' + 'str' + 'str' + 'str' + 'str' + 'str' + 'str' + \
'str' + 'str' + 'str' + 'str' + 'str' + 'str' + \
'str' + 'str' + 'str' + 'str' + 'str' + 'str' |
github-actions
bot
added
the
info-needed
Issue requires more information from poster
label
Dec 13, 2023
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Labels
info-needed
Issue requires more information from poster
triage-needed
Needs assignment to the proper sub-team
Type: Bug
Behaviour
Expected vs. Actual
Expected: Upon saving the file, f-strings on long lines are not broken at string literals, or have
\
added to the EOL.Actual: Upon saving the file, f-strings on long lines get incorrect line breaks, causing "unterminated string literal" or "EOL while scanning string literal". If one attempts to fix the line break with a
\
, autoFormat removes that upon save. It's impossible to have a file with an f-string on a long line, autoFormat has to be disabled.Steps to reproduce:
settings.json
:Diagnostic data
python.languageServer
setting: DefaultExtension version: 2023.8.0
VS Code version: Code 1.78.0 (252e5463d60e63238250799aef7375787f68b4ee, 2023-05-03T20:15:29.774Z)
OS version: Darwin arm64 23.1.0
Modes:
Sandboxed: No
The text was updated successfully, but these errors were encountered: