From 3c7525ba73ece2438b303ab975bcec9958f13aa7 Mon Sep 17 00:00:00 2001 From: bcolsen Date: Sat, 17 Dec 2016 00:33:38 -0700 Subject: [PATCH] ADD: Get return types for CompiledObjects using docstrings.py --- jedi/evaluate/compiled/__init__.py | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/jedi/evaluate/compiled/__init__.py b/jedi/evaluate/compiled/__init__.py index f004a142a..bfaa0c3d3 100644 --- a/jedi/evaluate/compiled/__init__.py +++ b/jedi/evaluate/compiled/__init__.py @@ -78,6 +78,13 @@ def is_class(self): @property def doc(self): return inspect.getdoc(self.obj) or '' + + @property + def raw_doc(self): + try: + return unicode(self.doc) + except NameError: # python 3 + return self.doc @property def params(self): @@ -196,9 +203,12 @@ def name(self): return FakeName(name, self) def _execute_function(self, params): + from jedi.evaluate import docstrings if self.type != 'funcdef': return - + types = set([]) + types |= set(docstrings.find_return_types(self._evaluator, self)) + debug.dbg('docstrings type return: %s in %s', types, self) for name in self._parse_function_doc()[1].split(): try: bltn_obj = getattr(_builtins, name) @@ -210,8 +220,9 @@ def _execute_function(self, params): # TODO do we? continue bltn_obj = create(self._evaluator, bltn_obj) - for result in self._evaluator.execute(bltn_obj, params): - yield result + types |= set(self._evaluator.execute(bltn_obj, params)) + for result in types: + yield result @property @underscore_memoization