2011-08-30 95 views
1

在我的代码中,我使用编译扩展的对象(在我的例子中为igraph)。我使用PyLint分析代码。 PyLint抱怨丢失的属性(如igraph的Graph.adjacent),虽然它明显存在(代码无误地运行)。这个消息可能是什么原因?PyLint错误地表示缺少某些属性的对象

下面是一些测试代码

import igraph 
gr = igraph.Graph(10)#create a graph with 10 vertices 
edges = gr.es #no pylint errors 
vertices = gr.vs #no pylint errors 
print gr.are_connected(0, 1) #pylint error E1101 
print gr.adjacent(0) #pylint error E1101 

这是pylint的输出:

************* Module temp 
C0111: 1: Missing docstring 
C0103: 2: Invalid name "gr" (should match (([A-Z_][A-Z0-9_]*)|(__.*__))$) 
C0103: 3: Invalid name "edges" (should match (([A-Z_][A-Z0-9_]*)|(__.*__))$) 
C0103: 4: Invalid name "vertices" (should match (([A-Z_][A-Z0-9_]*)|(__.*__))$) 
E1101: 5: Instance of 'Graph' has no 'are_connected' member 
E1101: 6: Instance of 'Graph' has no 'adjacent' member 

PS:IGRAPH 在我的PYTHONPATH

+0

请提供一些代码。 –

+0

@Dhaivat Pandya谢谢,添加示例 –

+0

是您的Python路径上的igraph? –

回答

1

,如果它是一个编译的C扩展名,Pylint可以做的很少,因为它无法分析源代码。你可以在交互式shell中打印igraph.Graph.are_connected吗?如果没有,这意味着库在实例化时可能会做一些奇怪的事情,或者这些方法是内省的。

在任何情况下,这是一个棘手的问题,对于pylint。

您可以使用http://www.logilab.org/ticket/73978(最近包含在开发树中)提供的修补程序,或忽略带有内联指令的E1101。