[pylint] upgrade pylintext plugin
authorLaura Médioni <laura.medioni@logilab.fr>
Tue, 19 Jan 2016 11:43:52 +0100
changeset 11217 1f686f55ef3d
parent 11216 efecb78bf929
child 11218 3fea2f3b25c1
[pylint] upgrade pylintext plugin
cubicweb/pylintext.py
--- a/cubicweb/pylintext.py	Tue Jan 19 13:24:44 2016 +0100
+++ b/cubicweb/pylintext.py	Tue Jan 19 11:43:52 2016 +0100
@@ -1,11 +1,12 @@
-"""https://pastebin.logilab.fr/show/860/"""
+"""Pylint plugin for cubicweb"""
 
-from astroid import MANAGER, InferenceError, nodes, scoped_nodes
+from astroid import MANAGER, InferenceError, nodes, scoped_nodes, ClassDef, FunctionDef
 from astroid.builder import AstroidBuilder
 
+
 def turn_function_to_class(node):
     """turn a Function node into a Class node (in-place)"""
-    node.__class__ = scoped_nodes.Class
+    node.__class__ = ClassDef
     node.bases = ()
     # remove return nodes so that we don't get warned about 'return outside
     # function' by pylint
@@ -19,7 +20,7 @@
     # is kept). Only look at module level functions, should be enough.
     for assnodes in module.locals.values():
         for node in assnodes:
-            if isinstance(node, scoped_nodes.Function) and node.decorators:
+            if isinstance(node, FunctionDef) and node.decorators:
                 for decorator in node.decorators.nodes:
                     try:
                         for infered in decorator.infer():
@@ -45,6 +46,7 @@
 ''')
         module.locals['data'] = fake.locals['data']
 
+
 def register(linter):
     """called when loaded by pylint --load-plugins, nothing to do here"""
     MANAGER.register_transform(nodes.Module, cubicweb_transform)