summaryrefslogtreecommitdiff
path: root/pylint/pyreverse
diff options
context:
space:
mode:
authorClaudiu Popa <pcmanticore@gmail.com>2015-08-25 21:06:19 +0300
committerClaudiu Popa <pcmanticore@gmail.com>2015-08-25 21:06:19 +0300
commit5c8afd6b7472767e4fa4ab7d97b51a9afb80d3b2 (patch)
tree95fe7a46ee994e27542fb42f31e7b54935ad5aac /pylint/pyreverse
parent489e01057de4028887af7b6842621914816abea5 (diff)
downloadpylint-5c8afd6b7472767e4fa4ab7d97b51a9afb80d3b2.tar.gz
Update pylint to use the new astroid AST names and methods
Also improve a couple of imports and added support for the old visit_ names. Priority will have the old visit_ names, such as visit_discard over visit_expr, visit_callfunc over visit_call etc.
Diffstat (limited to 'pylint/pyreverse')
-rw-r--r--pylint/pyreverse/diadefslib.py6
-rw-r--r--pylint/pyreverse/diagrams.py6
-rw-r--r--pylint/pyreverse/inspector.py20
3 files changed, 16 insertions, 16 deletions
diff --git a/pylint/pyreverse/diadefslib.py b/pylint/pyreverse/diadefslib.py
index 0ef1465..6c2cb3c 100644
--- a/pylint/pyreverse/diadefslib.py
+++ b/pylint/pyreverse/diadefslib.py
@@ -104,7 +104,7 @@ class DiaDefGenerator(object):
for ass_node in ass_nodes:
if isinstance(ass_node, astroid.Instance):
ass_node = ass_node._proxied
- if not (isinstance(ass_node, astroid.Class)
+ if not (isinstance(ass_node, astroid.ClassDef)
and self.show_node(ass_node)):
continue
yield ass_node
@@ -163,7 +163,7 @@ class DefaultDiadefGenerator(LocalsVisitor, DiaDefGenerator):
self.linker.visit(node)
self.pkgdiagram.add_object(node.name, node)
- def visit_class(self, node):
+ def visit_classdef(self, node):
"""visit an astroid.Class node
add this class to the class diagram definition
@@ -171,7 +171,7 @@ class DefaultDiadefGenerator(LocalsVisitor, DiaDefGenerator):
anc_level, ass_level = self._get_levels()
self.extract_classes(node, anc_level, ass_level)
- def visit_from(self, node):
+ def visit_importfrom(self, node):
"""visit astroid.From and catch modules for package diagram
"""
if self.pkgdiagram:
diff --git a/pylint/pyreverse/diagrams.py b/pylint/pyreverse/diagrams.py
index f0d7a92..dfc03f2 100644
--- a/pylint/pyreverse/diagrams.py
+++ b/pylint/pyreverse/diagrams.py
@@ -91,7 +91,7 @@ class ClassDiagram(Figure, FilterMixIn):
"""return visible methods"""
methods = [
m for m in node.values()
- if isinstance(m, astroid.Function) and self.show_attr(m.name)
+ if isinstance(m, astroid.FunctionDef) and self.show_attr(m.name)
]
return sorted(methods, key=lambda n: n.name)
@@ -109,7 +109,7 @@ class ClassDiagram(Figure, FilterMixIn):
for ass_node in nodes:
if isinstance(ass_node, astroid.Instance):
ass_node = ass_node._proxied
- if isinstance(ass_node, astroid.Class) \
+ if isinstance(ass_node, astroid.ClassDef) \
and hasattr(ass_node, "name") and not self.has_node(ass_node):
if ass_node.name not in names:
ass_name = ass_node.name
@@ -133,7 +133,7 @@ class ClassDiagram(Figure, FilterMixIn):
def classes(self):
"""return all class nodes in the diagram"""
- return [o for o in self.objects if isinstance(o.node, astroid.Class)]
+ return [o for o in self.objects if isinstance(o.node, astroid.ClassDef)]
def classe(self, name):
"""return a class by its name, raise KeyError if not found
diff --git a/pylint/pyreverse/inspector.py b/pylint/pyreverse/inspector.py
index b916008..b9712a7 100644
--- a/pylint/pyreverse/inspector.py
+++ b/pylint/pyreverse/inspector.py
@@ -157,7 +157,7 @@ class Linker(IdGeneratorMixIn, utils.LocalsVisitor):
if self.tag:
node.uid = self.generate_id()
- def visit_class(self, node):
+ def visit_classdef(self, node):
"""visit an astroid.Class node
* set the locals_type and instance_attrs_type mappings
@@ -185,7 +185,7 @@ class Linker(IdGeneratorMixIn, utils.LocalsVisitor):
except astroid.InferenceError:
node.implements = ()
- def visit_function(self, node):
+ def visit_functiondef(self, node):
"""visit an astroid.Function node
* set the locals_type mapping
@@ -199,10 +199,10 @@ class Linker(IdGeneratorMixIn, utils.LocalsVisitor):
link_project = visit_project
link_module = visit_module
- link_class = visit_class
- link_function = visit_function
+ link_class = visit_classdef
+ link_function = visit_functiondef
- def visit_assname(self, node):
+ def visit_assignname(self, node):
"""visit an astroid.AssName node
handle locals_type
@@ -223,10 +223,10 @@ class Linker(IdGeneratorMixIn, utils.LocalsVisitor):
# If the frame doesn't have a locals_type yet,
# it means it wasn't yet visited. Visit it now
# to add what's missing from it.
- if isinstance(frame, astroid.Class):
- self.visit_class(frame)
- elif isinstance(frame, astroid.Function):
- self.visit_function(frame)
+ if isinstance(frame, astroid.ClassDef):
+ self.visit_classdef(frame)
+ elif isinstance(frame, astroid.FunctionDef):
+ self.visit_functiondef(frame)
else:
self.visit_module(frame)
@@ -259,7 +259,7 @@ class Linker(IdGeneratorMixIn, utils.LocalsVisitor):
relative = modutils.is_relative(name[0], context_file)
self._imported_module(node, name[0], relative)
- def visit_from(self, node):
+ def visit_importfrom(self, node):
"""visit an astroid.From node
resolve module dependencies