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

Semicolon in f-string becomes newline #183

Closed
mpartel opened this issue Oct 25, 2023 · 5 comments
Closed

Semicolon in f-string becomes newline #183

mpartel opened this issue Oct 25, 2023 · 5 comments
Assignees
Labels
bug Issue identified by VS Code Team member as probable bug info-needed Issue requires more information from poster triage-needed

Comments

@mpartel
Copy link

mpartel commented Oct 25, 2023

x = 3
print(f'lol; {x}')

gets autoformatted to

x = 3
print(f'lol
{x}')

Same with double-quoted f-strings.

@mpartel
Copy link
Author

mpartel commented Oct 25, 2023

This does not happen when running autopep8 2.0.4 on the command line, even with 0-5 --aggressive flags.

@karthiknadig
Copy link
Member

@mpartel Can you set "autoepe8.trace.server": "verbose" in your user settings and attempt to format? This should generated detailed logs on Output >autopep8. Please share that log.

@karthiknadig
Copy link
Member

I tried running this locally, it seems to be formatting it as expected (this is from logs after setting "autoepe8.trace.server": "verbose")

2023-10-25 08:53:56.566 [info] file:///c%3A/GIT/scratch/autopep_test/sample.py :
****************************************************************************************************
x = 3
print(f'lol; {x}')

****************************************************************************************************

2023-10-25 08:53:56.567 [info] [Trace - 8:53:56 AM] Received response 'textDocument/formatting - (2)' in 230ms.
2023-10-25 08:53:56.567 [info] Result: [
    {
        "range": {
            "start": {
                "line": 2,
                "character": 0
            },
            "end": {
                "line": 2,
                "character": 0
            }
        },
        "newText": "\r\n"
    }
]

@karthiknadig karthiknadig added the info-needed Issue requires more information from poster label Oct 25, 2023
@karthiknadig karthiknadig self-assigned this Oct 25, 2023
@karthiknadig karthiknadig added the bug Issue identified by VS Code Team member as probable bug label Oct 25, 2023
@mpartel
Copy link
Author

mpartel commented Oct 25, 2023

Ah, this only happens if I have Python 3.12.0 (installed via pyenv) selected as the interpreter in VSCode. With 3.11.6 it works correctly.

Here's the log:
autopep8-trace.log

3.12.0 exhibits other f-string weirdness too, e.g.
print(f'lol:') becomes
print(f'lol: ')

@karthiknadig
Copy link
Member

@mpartel This seems to be a bug on autopep8 itself: hhatto/autopep8#712

@karthiknadig karthiknadig closed this as not planned Won't fix, can't repro, duplicate, stale Oct 25, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Issue identified by VS Code Team member as probable bug info-needed Issue requires more information from poster triage-needed
Projects
None yet
Development

No branches or pull requests

2 participants