Python and/or pylance is broken since last couple of updates
Type: Bug
Following the latest updates, using python is VS Code is a pain. A lot of useful features either became incredibly slow or broke completely.
On the latest updates, I no longer can use the Go To Definition, Find All References or Rename Symbol features.
If I switch to an older version it works fine.
Extension version: 2023.20.0 VS Code version: Code 1.85.2 (8b3775030ed1a69b13e4f4c628c612102e30a681, 2024-01-18T06:40:10.514Z) OS version: Windows_NT x64 10.0.22631 Modes:
System Info
| Item | Value |
|---|---|
| CPUs | 12th Gen Intel(R) Core(TM) i7-12700H (20 x 2688) |
| GPU Status | 2d_canvas: enabled canvas_oop_rasterization: enabled_on direct_rendering_display_compositor: disabled_off_ok gpu_compositing: enabled multiple_raster_threads: enabled_on opengl: enabled_on rasterization: enabled raw_draw: disabled_off_ok video_decode: enabled video_encode: enabled vulkan: disabled_off webgl: enabled webgl2: enabled webgpu: enabled |
| Load (avg) | undefined |
| Memory (System) | 15.69GB (2.00GB free) |
| Process Argv | --crash-reporter-id 624e2509-32c6-45d9-8be1-bcbd1e9605d0 |
| Screen Reader | no |
| VM | 0% |
A/B Experiments
vsliv368:30146709
vspor879:30202332
vspor708:30202333
vspor363:30204092
vswsl492cf:30256860
vscod805:30301674
binariesv615:30325510
vsaa593:30376534
py29gd2263:30899288
vsclangdf:30486550
c4g48928:30535728
azure-dev_surveyone:30548225
2i9eh265:30646982
0bi6i642:30933247
pythongtdpath:30769146
welcomedialogc:30910334
pythonidxpt:30866567
pythonnoceb:30805159
asynctok:30898717
pythontestfixt:30902429
pythonregdiag2:30936856
pyreplss1:30897532
pythonmypyd1:30879173
pythoncet0:30885854
pythontbext0:30879054
dsvsc016:30899300
dsvsc017:30899301
dsvsc018:30899302
what platform? R you opening a folder in VSCode? can you provide the "Python language sever" logs from the output window. see https://github.com/microsoft/pylance-release/blob/main/TROUBLESHOOTING.md#filing-an-issue
Are you using a local drive? Do you have a code sample/github repo with the code?
Yes I am opening a folder in VSCode. I cannot share my repo unfortunately.
I will share the logs if I siwtch back to the newer versions of the python/pylance extensions but for now I am sticking with the old versions (v2023.22.1 / v2023.11.10). It works fine with those.
The newer versions are broken. When is the next released planned ?
I'm facing a similar issue. I have turned on the trace logs and I noticed that pylance spends an awful lot of time parsing a ton of completely unrelated files. One such example was when I had a single python file of my project open and decided to use the "go to definition" feature. Pylance started parsing _pytest, test and other test related packages even though this file contained actual application code.
I can also confirm that if I uninstall pytest Pylance/VSCode gets much more responsive when I use "Go to definition". This could be related to https://github.com/microsoft/pylance-release/issues/4900
I noticed that the test package being scanned is not part of the active virtual enviroment but of the system-wide install of python3.11. After adding the following line to my workspace settings the problem was gone even with pytest installed:
"python.analysis.exclude": ["/usr/lib/python3.11/test/*"],
EDIT The above solution works for "Go to definition" if the destination file is part of the project. Otherwise, pylance will still search that package. For now I'll just rename that folder to something else which solves the problem for all cases.
I had similar experience back in September where pylance just plain stopped working (https://github.com/microsoft/pylance-release/issues/4884). Rolled back to older version (2023.8.30) and all functionality was restored. I just tried again this morning updating to latest release and it is still broken for me. Back to 2023.8.30. I will wait for a killer feature add before pursuing this again.
Downgrading to 2023.8.30. solved the problem for me. (For the curious: this is available on the pylance settings page as a drop-down-option "install other version" of the button "uninstall").
With current version (2024.2.105) I had unacceptable long times (>10s) with the spinning wheel (and a message like "analyzing 2 files") even for trivial changes in a trivial project. Unfortunately I have no idea how to debug this.
With version 2023.8.30 there most often is no perceptible time between my typing ends and analysis is completed.
The differences between the versions are also significantly noticeable in CPU load and thus fan speed (and thus noise).
Downgrading to 2023.8.30. solved the problem for me.
Turns out: this observation is not robust. Reality seems to be more like "sometimes pylance is fast and sometimes slow". I suspect it might be related to which packages I import. Usually I import numpy, sympy etc.
It would really help to understand, what is going on during the "analyzing files" wheel is spinning. Is there a way to write logfiles?
Edit 1: Also, it would help to have defined test scenario, e.g.:
- load project X,
- open file Y,
- goto line Z,
- paste
self.and - trigger autocompletion.
The menu should appear in < 1s. If this takes > 10 s then something is definitely wrong
If you're using sympy, then that's likely the culprit. See this issue here: https://github.com/microsoft/pyright/issues/7159
I'm not using sympy or numpy.
@Goose66 we'd need more information to address your issue. What exactly isn't working? Do you have a code sample that can reproduce the problem? Can you share a log.
I would be glad to provide additional info. I am a hobbyist programmer and occasional VS Studio user. Can you point me to the specific log files your require.
@goose66, I've created a new issue for you here: https://github.com/microsoft/pylance-release/issues/5575
I'll respond with what we'd need to reproduce the problem in that issue so we don't pollute the original poster's issue here.
I see some comments around pytest, can you guys try "python.analysis.enablePytestSupport": false and see whether it imrpoves perf? if it does, can you let us know so we can figure out more context together?
@vianmixtkz were you using a notebook?
No I wasn't using a notebook. It was quite a large backend FastAPI application in which I was using pandas and numpy among many other third party libraries.
But I don't think the size of the project nor the libraries that I used are the cause as it happened overnight and downgrading solve the issue for me.