From 7d39ccc360e0b359513fec3411738c3f7c426b4e Mon Sep 17 00:00:00 2001 From: David Halter Date: Sat, 3 Nov 2012 23:19:33 +0100 Subject: [PATCH] better type description of completion --- jedi/api.py | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/jedi/api.py b/jedi/api.py index 0734b28a..02440634 100644 --- a/jedi/api.py +++ b/jedi/api.py @@ -78,10 +78,15 @@ class Completion(object): except AttributeError: return '' - def get_type(self): - """ Returns the type of a completion object (e.g. Function/Class - TODO please don't use yet, behaviour may change in the future. """ - return type(self.name.parent()) + @property + def type(self): + """ Returns the type of a completion object (e.g. Function/Class) """ + if self.name.parent is None: + return '' + name_type = self.name.parent() + if isinstance(self.name_type, evaluate.InstanceElement): + name_type = name_type.var + return type(self.name_var).__class__ def __repr__(self): return '<%s: %s>' % (type(self).__name__, self.name)