本文介绍了VSVS IntelliSense的PTVS2.1无法正常工作的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经刷新数据库了!这个例子可以工作.
我的问题是IntelliSense在第5、6行上工作
但在第7行,tree(parameter)找不到方法xpath()
IntelliSense在第7行上不起作用,为什么?
我试图找到答案,有人说需要删除项目__init__.py可以解决此问题.
__init__.py在哪里?
还有其他解决问题的好方法吗?喜欢:更新VS2013?

I already refresh DB!The example can be work.
My problem is IntelliSense is work on line 5, 6
But at the line 7, tree(parameter) can't not find the method xpath()
IntelliSense is not work on line 7, why?
I try to find the answer, someone say need to Removing project __init__.py can fix the problem.
Where is the __init__.py ?
And there exists other good method to solve problem? like: update VS2013?

推荐答案

这实际上只是PTVS的局限性.要弄清tree的类型,需要弄清楚etree.parseHTMLParser传递时返回的etree.parse.根据parse中的代码,在没有实际执行的情况下,这几乎是不可能的.

This is actually just a limitation of PTVS. To figure out the type of tree, it needs to figure out what etree.parse will return when passed a StringIO and HTMLParser. Depending on the code in parse, this may be near impossible to do without actually executing it.

如果将鼠标悬停在tree上,我怀疑您会发现它是未知类型.要强制其具有某种类型,您可以编写:

If you hover over tree, I suspect you'll see that it is an unknown type. To force it to have a certain type, you can write:

assert isinstance(tree, WhateverType)

这将使PTVS知道它肯定是这种类型的,尽管在运行时如果您输入错误,程序将崩溃.添加对类型提示的支持后,您将可以改用这些类型的提示(但这可能需要更新到最新版本的Visual Studio).

This will let PTVS know that it will definitely be of that type, though at runtime your program will crash if you are wrong. When support for type hints is added, you will be able to use those instead (but that will likely require updating to the very latest version of Visual Studio).

这篇关于VSVS IntelliSense的PTVS2.1无法正常工作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-24 12:36