"Go to definition" option doesn't work in Visual Studio Code

"Go to definition" option doesn't work in Visual Studio Code. This happens with Python and methods/functions with multiple implementations.

In Pycharm I get a list of options. There is a similar thing in VS Code or a workaround for this? Thanks for your time!

VSCode screenshot

Pycharm screenshot

Upvotes: 1

Views: 532

Answers (1)

Masoud Rahimi
Masoud Rahimi

Reputation: 6041

You are calling methods from an object in the function argument, which is an unknown type. Therefore, you need to specify the argument type with annotation to inform the linter about the object type.

I assumed that ifp is a file IO object in typing.IO or if it is a user-defined type, you need to specify it explicitly.

from typing import IO


def peek_timestamp(ifp: IO):
    pos = ifp.tell()
    line = ifp.readline()
    ...

Upvotes: 1

Related Questions