forked from VimPlug/jedi
Make sure that the builtin docstring works again for infer calls
This commit is contained in:
@@ -120,6 +120,11 @@ def goto_or_help(request, Script):
|
||||
return lambda code, *args, **kwargs: getattr(Script(code), request.param)(*args, **kwargs)
|
||||
|
||||
|
||||
@pytest.fixture(scope='session', params=['goto', 'help', 'infer'])
|
||||
def goto_or_help_or_infer(request, Script):
|
||||
return lambda code, *args, **kwargs: getattr(Script(code), request.param)(*args, **kwargs)
|
||||
|
||||
|
||||
@pytest.fixture(scope='session')
|
||||
def has_typing(environment):
|
||||
if environment.version_info >= (3, 5, 0):
|
||||
|
||||
@@ -228,7 +228,12 @@ class ValueNameMixin(object):
|
||||
return ValueSet([self._value])
|
||||
|
||||
def py__doc__(self):
|
||||
return self._value.py__doc__()
|
||||
doc = self._value.py__doc__()
|
||||
if not doc and self._value.is_stub():
|
||||
from jedi.inference.gradual.conversion import convert_names
|
||||
names = convert_names([self], prefer_stub_to_compiled=False)
|
||||
return _merge_name_docs(names)
|
||||
return doc
|
||||
|
||||
def _get_qualified_names(self):
|
||||
return self._value.get_qualified_names()
|
||||
|
||||
@@ -89,3 +89,11 @@ def test_version_info(Script):
|
||||
|
||||
c, = s.completions()
|
||||
assert c.docstring() == 'sys.version_info\n\nVersion information as a named tuple.'
|
||||
|
||||
|
||||
def test_builtin_docstring(Script, goto_or_help_or_infer):
|
||||
d, = goto_or_help_or_infer('open')
|
||||
|
||||
doc = d.docstring()
|
||||
assert doc.startswith('open(file: Union[')
|
||||
assert 'Open file' in doc or 'Open a file' in doc
|
||||
|
||||
Reference in New Issue
Block a user