Go to definition in VS code doesn't show the body of a function

1.5k Views Asked by At

When I right click on a function and then select "Go to definition" there shows up a module with that function, but it only shows the parameters which have to be passed to it, and I can't see anything about the body of the function.

Here is what's shown when I went to the definition of itertools.dropwhile:

go-to-definition

2

There are 2 best solutions below

0
On BEST ANSWER

As mentioned in the comments, VSCode can only show you source code it has access to, and many of the Python builtins and stdlib (including the itertools module) are implemented in compiled C -- there's no source code to show you.

1
On

Sometimes this happens if you develop code that runs inside an environment whose libraries are not visible in your main OS.

One way to solve this is by opening the terminal in VSCode and doing a pip install <library> to install the library and make VSCode aware of it.