diff options
author | spaceone <devnull@localhost> | 2015-10-12 21:52:37 +0200 |
---|---|---|
committer | spaceone <devnull@localhost> | 2015-10-12 21:52:37 +0200 |
commit | 6659e420cec3a1db49efc6bb916886e56c2d5e78 (patch) | |
tree | 5192f228a0c66aaf4f96fd8366d17b231f2b2c57 | |
parent | 4e82b39a1e0e2329de4df11cd79740a5455b7b5d (diff) | |
download | pylint-6659e420cec3a1db49efc6bb916886e56c2d5e78.tar.gz |
display properties as attributes in pyreverse class diagram
-rw-r--r-- | ChangeLog | 3 | ||||
-rw-r--r-- | pylint/pyreverse/diagrams.py | 15 |
2 files changed, 16 insertions, 2 deletions
@@ -2,6 +2,9 @@ ChangeLog for Pylint -------------------- -- + * Property methods are shown as attributes instead of functions in + pyreverse class diagrams. Closes Issue #284 + * Add checker to identify multiple imports on one line. Closes issue #598. diff --git a/pylint/pyreverse/diagrams.py b/pylint/pyreverse/diagrams.py index dfc03f2..ef7fe90 100644 --- a/pylint/pyreverse/diagrams.py +++ b/pylint/pyreverse/diagrams.py @@ -18,10 +18,13 @@ import astroid from pylint.pyreverse.utils import is_interface, FilterMixIn +from pylint.checkers.utils import decorated_with_property + class Figure(object): """base class for counter handling""" + class Relationship(Figure): """a relation ship from an object in the diagram to another """ @@ -41,6 +44,7 @@ class DiagramEntity(Figure): self.title = title self.node = node + class ClassDiagram(Figure, FilterMixIn): """main class diagram handling """ @@ -77,8 +81,13 @@ class ClassDiagram(Figure, FilterMixIn): def get_attrs(self, node): """return visible attributes, possibly with class name""" attrs = [] + properties = [ + (n, m) for n, m in node.items() + if isinstance(m, astroid.FunctionDef) + and decorated_with_property(m) + ] for node_name, ass_nodes in list(node.instance_attrs_type.items()) + \ - list(node.locals_type.items()): + list(node.locals_type.items()) + properties: if not self.show_attr(node_name): continue names = self.class_names(ass_nodes) @@ -91,7 +100,9 @@ class ClassDiagram(Figure, FilterMixIn): """return visible methods""" methods = [ m for m in node.values() - if isinstance(m, astroid.FunctionDef) and self.show_attr(m.name) + if isinstance(m, astroid.FunctionDef) + and not decorated_with_property(m) + and self.show_attr(m.name) ] return sorted(methods, key=lambda n: n.name) |