简体   繁体   中英

“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

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()
    ...

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM