[英]“Go to definition” option doesn't work in Visual Studio Code
"Go to definition" option doesn't work in Visual Studio Code. “转到定义”选项在 Visual Studio Code 中不起作用。 This happens with Python and methods/functions with multiple implementations.
这发生在 Python 和具有多个实现的方法/函数中。
In Pycharm I get a list of options.在 Pycharm 中,我得到了一个选项列表。 There is a similar thing in VS Code or a workaround for this?
VS Code 中有类似的东西或解决方法吗? Thanks for your time!
谢谢你的时间!
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.
因此,您需要使用注释指定参数类型,以通知 linter 对象类型。
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.我认为
ifp
是在文件IO对象typing.IO
或者如果它是一个用户定义类型,你需要明确指定它。
from typing import IO
def peek_timestamp(ifp: IO):
pos = ifp.tell()
line = ifp.readline()
...
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.