From 632072000efd0a7218f792dc588a529166043ef7 Mon Sep 17 00:00:00 2001 From: Dave Halter Date: Mon, 3 Apr 2017 00:27:31 +0200 Subject: [PATCH] Fix the builtin docstring issue that we've had. Fixes #859. --- jedi/api/classes.py | 6 ++++++ test/test_evaluate/test_compiled.py | 6 ++++++ 2 files changed, 12 insertions(+) diff --git a/jedi/api/classes.py b/jedi/api/classes.py index 74592d9d..b7b2431f 100644 --- a/jedi/api/classes.py +++ b/jedi/api/classes.py @@ -701,6 +701,12 @@ class _Help(object): @memoize_method def _get_node(self, fast): + if isinstance(self._name, (compiled.CompiledContextName, compiled.CompiledName)): + followed = self._name.infer() + if followed: + return next(iter(followed)) + return None + if self._name.api_type == 'module' and not fast: followed = self._name.infer() if followed: diff --git a/test/test_evaluate/test_compiled.py b/test/test_evaluate/test_compiled.py index 0f7620a7..899f56af 100644 --- a/test/test_evaluate/test_compiled.py +++ b/test/test_evaluate/test_compiled.py @@ -83,3 +83,9 @@ def test_method_completion(): else: result = ['__func__'] assert [c.name for c in Script(code).completions()] == result + + +def test_time_docstring(): + import time + comp, = Script('import time\ntime.sleep').completions() + assert comp.docstring() == time.sleep.__doc__