2011-08-30 93 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。