-
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
Indentation Errors in VS Code When Running Old Python Functions with Docstrings/Comments Using Shift + Enter #24069
Comments
Looks like someone else is experiencing the same issue: #24083 |
Interesting. I could replicate it in a freshly created file though. I also tried setting up a new venv. |
@thunfischtoast Yea I can get the bug to go away with fresh functions. If I "edit" old functions to make them "new" then the issue persists. |
Do the "old" functions maybe have indentations in the blank lines? E.g. this fails:
but this works:
|
Thanks everyone for staying on top of this. @kitman1250 Are you on https://github.com/microsoft/vscode-python/releases/tag/v2024.14.0 2024.14.0? If so, can you downgrade to 2024.12.0 and see if you observe the same problem - thanks |
@anthonykim1 Yes that fixed it! v2024.12.0. I had reverted a few extensions to older versions before without it fixing the issue, so I must have either used the reverted the wrong ones before (maybe Pylance?) or I didn't go back far enough to v2024.12.0. I toggled it back and forth a few times between the newest version and this version, and this definitely fixes the issue. |
…24096) Reverts microsoft#23977 Have to revert microsoft#23977 with issue: microsoft#23743 due to microsoft#24069 Will revisit why microsoft#23743 is breaking if contained inside other top level (in ast term) code block, and look into how to support microsoft#23743 without breaking.
…24096) Reverts microsoft#23977 Have to revert microsoft#23977 with issue: microsoft#23743 due to microsoft#24069 Will revisit why microsoft#23743 is breaking if contained inside other top level (in ast term) code block, and look into how to support microsoft#23743 without breaking.
Can folks please try the latest pre-release version of the Python extension and let me know if the problem is resolved? |
I encountered the same issue and had to revert to an earlier version. The pre-release update resolved the problem. |
Same here, the problem does not occur on |
Same, no issue on v2024.15.2024091202. Thank you @anthonykim1! |
Great, thank you everyone. Python extension 2024.14.1 is now released and it should have all the fixes for this! Let me know if anyone suffer from this problem again. |
…24096) Reverts microsoft#23977 Have to revert microsoft#23977 with issue: microsoft#23743 due to microsoft#24069 Will revisit why microsoft#23743 is breaking if contained inside other top level (in ast term) code block, and look into how to support microsoft#23743 without breaking.
Summary
When running my "old" Python functions in VS Code using Shift + Enter (Python Interactive Window), I encounter indentation errors on lines that contain single (') or double (") quotes at the beginning, particularly with comments or docstrings. However, if I write brand new functions with similar comments or docstrings, they run without any issues. By "old" functions, I just mean anything that is saved in a file, not written brand new. Reinstalling Python did not resolve the problem, and the issue persists even though the code is properly formatted with consistent indentation. I've been running code this way all year without issue, but this week I've started having issues.
GIF reproducing error is below
Steps to Reproduce:
Expected Behavior:
The code should execute without indentation errors when running individual functions or code blocks, as it does when the entire script is run.
Actual Behavior:
Indentation errors occur when running individual functions with Shift + Enter, specifically related to lines with comments or docstrings.
System Information:
Operating System: Windows
OS Version: 10.0.22631
OS Release: 11
VS Code Version: 1.93
Python Version: 3.12.5
Pylance: v2024.8.2
GIF Example:
GIF: https://imgur.com/ueBj9xM
The text was updated successfully, but these errors were encountered: