-
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
Python3.13 All functions fail to send: IndentationError: unexpected indent #24256
Comments
I am experiencing the same. Version: 1.94.2 (system setup) |
Same behaviour and error, only happens with python 3.13, 3.12 works fine. |
Thanks for the bug report! We investigate issues in order based on priority and severity, which includes the impact it has on your ability to use the extension to do productive work, and the number of people affected. If other users come forward and leave a comment demonstrating they are seeing/reproducing the problem then we will raise this issue's priority. Thanks for understanding and the patience! Please go ahead and upvote this meanwhile so that we can further acknowledge the severity. |
Regarding severity, it greatly inhibited my ability to do work. Testing individual blocks of code is no longer a viable option for me. I cannot copy paste, I cannot shift+enter, I cannot right click and run in interactive window... I have to modify the python code, then to non-interactively test I run the entire program that calls the python. Dramatic decrease in productivity as a result of tedious testing and debugging. |
For me and students of our classes the impact is also huge. We teach the first steps of Python programming by letting them run blocks of code using shift+enter, but with the new behavior this is no longer an option at all. |
I just wanted to add that this also severely impacts how I use Python 3.13 in Visual Studio Code. For those looking for a workaround (other than downgrading Python to ≤ 3.12 or setting the env variable |
BTW, just to let Windows users know that this currently does not work in Windows Terminal either, see python/cpython#124119. |
I updated VS Code to the most updated version (1.95.0) but still have the same error with Python 3.13 on Windows and Mac OS. |
Thanks @cbrnr for
Thanks everyone for the feedback here. Team is actively looking into resolving this, but please try out the "Native REPL" setting to send code and execute in Native REPL instead of terminal meanwhile. |
@cbrnr The type of indentation error we can get seems very similar from what you mentioned python/cpython#124096 (issue from referenced PR). I think the indentation problem is not contained for just windows as we are experiencing for MacOS and linux too. |
I am having the same issue and would hope to see a fix on python 3.13 with integration to VSCode. Reverted to python 3.12 and no problems Hoping @anthonykim1 you will be to look into this with your team, Appreciate the help |
Hey folks, good news here: I've resolved the issue for 3.13 on this PR: #24401 Edit: /cc @benichou apologies for confusion here, we don't release pre-release on weekend so it will build Monday morning and will be available Monday afternoon, or Tuesday if that is easier for you. Let me know how this goes for your specific operating system (Mac, Windows, Linux) |
Thanks will check it out!
Best Regards,
Bien cordialement,
Franck BENICHOU
…On Fri, Nov 8, 2024 at 3:37 PM Anthony Kim ***@***.***> wrote:
Hey folks, good news here:
I've resolved the issue for 3.13 on this PR.
That being said, please try Python extension's pre-release on VS Code
insiders starting tomorrow, November 9th.
Let me know how this goes.
Thanks!
—
Reply to this email directly, view it on GitHub
<#24256 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/ACO7WPXY6WTQRMKGQ2L6IILZ7UOIXAVCNFSM6AAAAABPNP652KVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDINRVG4YDSMJWGI>
.
You are receiving this because you commented.Message ID:
***@***.***>
|
https://github.com/user-attachments/assets/2b72da8e-ca04-447e-8e14-7eaed1c6bd9d |
I just tried again with the regular release (no preview), and the indentation is now correctly transferred to the REPL. However, I do get a
before every executed command: def f(x):
if x > 0:
return 1
elif x < 0:
return -1
else:
return 0
print(f(42)) Running these two commands with Shift-Enter results in:
|
Thanks, now the |
I'm not sure if I'm doing something wrong, but on Windows, hitting Shift-Enter on a line of code does not even start the interactive interpreter. It just pastes the current line into the Terminal, which is running PowerShell. I don't usually work on Windows, but I've synced my VSC settings, which do work on macOS and Linux. Maybe some keyboard shortcut conflict? Both "Python: Run Selection/Line in Python REPL" and "Python: Run Selection/Line in Python Terminal" are bound to Shift-Enter. OK, "Python: Run Selection/Line in Python Terminal" is the correct command, and disabling the other at least runs the selected block of code in the interpreter. Not sure what the difference between these two commands is though. However, on Windowsit still doesn't work, because every line is getting additional indentation probably due to python/cpython#124119. |
Hey @cbrnr Thanks much for testing this thoroughly :) The difference is the Python Terminal one is supposed to send code to your terminal REPL (one with >>> while the Python REPL one sends code to native REPL https://code.visualstudio.com/docs/python/run#_native-repl Im not sure if you manually changed your shortcut, but the shift+enter behavior should change dynamically depending on your setting: Let me know how things go with playing around with these settings. And yes you are absolutely correct for:
|
No problem, I'm using Visual Studio Code and the Python Extension for teaching, that's why I keep finding and reporting things 😄. I have also asked this in a discussion thread #24443. I'll answer over there since this issue is already closed (and my comment is not even related to this issue here). |
For anyone interested in more discussions for native repl (new editor based vscode native python repl) vs. terminal repl (interactive interpreter with >>>). Here is the link: #24443 For rest of other folks the indentation should be fixed on the latest pre-release version of Python extension on VS Code Insiders :) |
I am still experiencing the issue, the same way as before: #24256 (comment) I uninstalled every extension but python's: I am using the pre-lease version: the python version of 3.13.0 64-bit: Started a new window, a brand new py file but after shift+enter, the same behaviour is found as before: Also, if i ctrl c ctrl v the code into the terminal, extra indents are added just by the copying of the code into the terminal: As for others the error is fixed (or at least for one people with feedback), could you give any advice in what I could do to make this work? Thanks |
Are you on Windows? There's another bug which affects only Windows (linked in a previous comment). |
Related on Stack Overflow: |
on fedora 41 with Python 3.13.0 (main, Oct 8 2024, 00:00:00) [GCC 14.2.1 20240912 (Red Hat 14.2.1-3)] with visual studio code 1.95.3 and pylance v2024.11.3 I still see it happening: KeyboardInterrupt
|
Seems like the pre release version of the Python Extension has fixed it for me v2024.21.2024112701 (pre-release) VS Code Version: 1.95.3 |
@srdgtr You should try it on latest VS Code Insiders and latest version of Python extension PRE-RELEASE. |
Fixes for indentation error should be effective for latest VS Code insider and latest pre-release of Python extension for MacOS & Linux FYI: Windows users with Python3.13 (regardless of VS Code terminal or external terminal) are still suffering from indentation error from: python/cpython#124096 If you are on mac or linux please make sure indentation error has been resolved when using Python REPL in VS Code terminal. Verification steps (Mac and Linux)
Verification steps (Windows)
|
I failed to install Python 3.13 into my Python dev container using
Any tips? |
@dbaeumer Install |
@anthonykim1 - using the pre-release version of the plugin, it appears the indentation issue was fixed, but the behavior of selected lines sent to the REPL appears to have changed. With a selection as pictured: If I send to the repl with
With the release version
|
Hi @dangets Thanks for trying this out. This is actually coming from cpython itself - as they have tweaked indentation execution in the new Pyrepl. To get a better understanding of this, you can create a REPL outside of VS Code (external terminal) and then try copying and pasting couple lines of code and you would be able to see how the behavior changed. Glad that indentation error specific to VS Code was resolved by us :) |
@karthiknadig thanks |
@anthonykim1 - I'm not sure I follow your point about the new pyrepl. I was using the same version of python (3.13.1), but only changing the vscode plugin version and seeing different behavior. Your example is switching between python 3.13.0 and 3.12.5 |
@dangets I mean that you should notice the change in behavior (such as trailing ...) when comparing 3.12.5 vs. 3.13.0 REP. You should notice the copy-pasting & indentation behavior has changed from Python itself from 3.12 vs. 3.13
The one you were seeing v2024.20.0 (with broken indentation if you had functions or class in your example), wouldn't be accurate example of experience we are aiming for. You should compare our terminal REPL's behavior with cpython's REPL behavior when comparing indentation and copy and pasting behavior. |
@anthonykim1 - My concern is that there is a regression in the upcoming pre-release version that changes the send-to-repl behavior. I don't really care about the preceding With the pre-release version of the plugin - the editor is left hanging and I have to click on the repl and hit enter for it to execute the sent lines. With the existing stable version, I don't have to do this step. I am assuming that this regression was introduced as a result of the change to fix the indentation issue. Again - this is using the same version of python and only changing the vscode plugin version. |
Discussed in #24222
Originally posted by ddxv October 2, 2024
I recently fired up Python3.13rc2 but quickly found that any lines I send to the terminal do not work, specifically anything with additional line breaks or with indentation.
The new REPL, as I'm sure you know, autoindents for users. So it appears I'm getting a new indent for each line + the existing indent, causing a deeper and deeper indent even on a flat function. As you can see in the screenshot:
This inevitably leads to:
IndentationError: unexpected indent
I'm opening a discussion because I don't see others mentioning this for Python 3.13, so I was not sure if this is actually a bug or something unique to my settings?
If others are encountering this, happy to turn this into a ticket.
The text was updated successfully, but these errors were encountered: