In my code I use object from compiled extensions (in my case, igraph). I use PyLint to analyze the code. PyLint complains about missing attributes (such as igraph's Graph.adjacent
), while it clearly exists (the code runs without errors). What might be the cause for this messages?
Here is some test code
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
And this is the output of pylint:
************* Module temp
C0111: 1开发者_如何学Go: 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 is in my PYTHONPATH
if it is a compiled C extension, there is little Pylint can do, as it cannot analyze the source code. Can you print igraph.Graph.are_connected in an interactive shell ? If not, it means that the library probably does some weird things at instantiation time or that the methods are introspected.
In any case this is a tricky problem for pylint.
You could use the patch provided on http://www.logilab.org/ticket/73978 (recently included in the dev tree) or ignore E1101 with inlined directives.
精彩评论