Pylance does not allow me to navigate to the source code, bringing me to the .pyi stub instead

Viewed 1700

I am using pylance for vs code and it works really nice, except that since I use it, when I try to check code from an installed library, I can get only to the stub, I think generated by pylance.

For example, the information shown about the function: enter image description here

Or, crtl + click on the function brings me to the .pyi stub, which at
~/.vscode-server/extensions/ms-python.vscode-pylance-2020.11.0/dist/bundled/stubs/pandas/io/parsers.pyi

I can't find a way to navigate to the actual code (of pandas in this case).

If I deactivate Pylance and use Microsoft as language server by setting "python.languageServer": "Microsoft", in setting.json, the navigation to the library works fine.

Is it possible to navigate to the actual code with pylance active?

OS: Ubuntu 18.04
Visual Studio Code: Version: 1.50.1
Pylance: v2020.11.0

3 Answers

Let's remove ~/.vscode-server/extensions/ms-python.vscode-pylance-2020.11.0/dist/bundled/stubs/pandas

Then reload vscode

I had the same issue and realized I was using Docker. So I set up virtualenv and installed Django using pip. Then I switched Python interpreter in the bottom-left corner of VS Code and it started working.

I know this is a specific case but I hope this answer helps someone in the same problem.

enter image description here

You can navigate to the references by right-clicking on the symbol and selecting "Go to References".

Also, ensure that you have a Python interpreter configured for the script where pandas is installed.

You can select an interpreter by opening Command Palette from the View menu and typing in "Python: Select Interpreter" and following through the dialog.

When you have that set, you should see two references when you Ctrl + click on a symbol: one for the stub and the other from the library.

enter image description here

Related