microsoft / pylance-release

Documentation and issues for Pylance
Creative Commons Attribution 4.0 International
1.7k stars 769 forks source link

Python stubs loaded from extensions folder even when using an explicit interpreter #5444

Closed Always-Self-Hosted closed 7 months ago

Always-Self-Hosted commented 7 months ago

Type: Bug

  1. Set an interpreter that isn't default (I'm using one in a venv)
  2. Install custom stubs to that venv (I did pip install micropython-esp8266-stubs
  3. Open a python file using packages installed in that venv that you have stubs for (I am using gc and machine)
  4. Observe that the machine import lints correctly and if you go to definition it will open the .pyi file in that venv location, but if you do the same for the gc package it opens the .pyi file in the default extension location (in my example, it opens the path to the jedi/third_party/typeshed/stdlib file)

I'm happy to be told im wrong, but this seems like an oversight to me. In my program i am getting lint warnings, and not getting function previews/type hints for my correct code, because the implementation of gc from micropython is different to the python standard library gc, but i am developing in a venv for this reason, and i can't seem to find any extension settings that allow me to explicitly tell vs code (or in my case, vscodium) to only use stubs in my venv location (or atleast change the priority order that they are looked for)

Extension version: 2024.0.0 VSCodium version: VSCodium 1.82.2 (a5004432af6600c99fa4f918a3f2f8df44df71e6, 2023-09-14T18:27:11.315Z) OS version: Linux x64 6.1.0-17-amd64 Modes:

System Info |Item|Value| |---|---| |CPUs|AMD Ryzen 7 1700 Eight-Core Processor (16 x 1421)| |GPU Status|2d_canvas: enabled
canvas_oop_rasterization: disabled_off
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: disabled_software
vulkan: disabled_off
webgl: enabled
webgl2: enabled
webgpu: disabled_off| |Load (avg)|1, 1, 1| |Memory (System)|31.27GB (25.97GB free)| |Process Argv|--unity-launch| |Screen Reader|no| |VM|0%| |DESKTOP_SESSION|cinnamon| |XDG_CURRENT_DESKTOP|X-Cinnamon| |XDG_SESSION_DESKTOP|cinnamon| |XDG_SESSION_TYPE|x11|
rchiodo commented 7 months ago

I believe if you're using VS codium, you must be using jedi as your language server, not pylance.

"python.languageServer": "jedi"

As Pylance doesn't run in VS Codium. Or at least it shouldn't.

That should mean this is an issue for the Jedi language server.

debonte commented 7 months ago

If Pylance is actually in use, this might be a dupe of https://github.com/microsoft/pylance-release/issues/5031.

Always-Self-Hosted commented 7 months ago

Thank you for responding to this issue. This definitely seems to be a misunderstanding on my part then, because for some reason i thought pylance was the one that controls if it uses itself, or jedi as a fallback, as the lsp, not vscodium.

Thank you for clarifying. I'll move the issue to the jedi project.