summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorClaudiu Popa <pcmanticore@gmail.com>2015-11-05 17:17:19 +0200
committerClaudiu Popa <pcmanticore@gmail.com>2015-11-05 17:17:19 +0200
commit60c8b26efc81e78e9612d3eee0fa13edd2f52edb (patch)
tree7012d50c72e79261a176e44643a929b363a26427
parente95781ae23b53a1c3808d974fd3886af26cb5dc7 (diff)
parent6659e420cec3a1db49efc6bb916886e56c2d5e78 (diff)
downloadpylint-60c8b26efc81e78e9612d3eee0fa13edd2f52edb.tar.gz
Merge
-rw-r--r--ChangeLog4
-rw-r--r--pylint/pyreverse/diagrams.py15
2 files changed, 17 insertions, 2 deletions
diff --git a/ChangeLog b/ChangeLog
index 6ad85d5..39b70c5 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -2,6 +2,10 @@ ChangeLog for Pylint
--------------------
--
+
+ * Property methods are shown as attributes instead of functions in
+ pyreverse class diagrams. Closes Issue #284
+
* Add a new refactoring error, 'too-many-nested-blocks', which is emitted
when a function or a method has too many nested blocks, which makes the
code less readable and harder to understand. Closes issue #668.
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)