Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

PR: Return types for CompiledObjects using docstrings.py #818

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 14 additions & 3 deletions jedi/evaluate/compiled/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down Expand Up @@ -196,9 +203,12 @@ def name(self):
return FakeName(name, self)

def _execute_function(self, params):
from jedi.evaluate import docstrings
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is necessary due to cyclical importing of CompliedObject in analysis.py which is import by docstrings.py through iteratable.py

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)
Expand All @@ -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
Expand Down