Repository: spyder-ide/spyder

Issue:
Error when getting completions with Jedi 0.15
## Description

### What steps will reproduce the problem?

<!--- You can use Markdown here --->

import pandas as pd
pd. < press tab or ctlr+space >

### Traceback
```python-traceback
  File "/home/apostolos/miniconda3/envs/forex/lib/python3.7/site-packages/pyls_jsonrpc/endpoint.py", line 113, in consume
    self._handle_request(message['id'], message['method'], message.get('params'))
  File "/home/apostolos/miniconda3/envs/forex/lib/python3.7/site-packages/pyls_jsonrpc/endpoint.py", line 182, in _handle_request
    handler_result = handler(params)
  File "/home/apostolos/miniconda3/envs/forex/lib/python3.7/site-packages/pyls_jsonrpc/dispatchers.py", line 23, in handler
    return method(**(params or {}))
  File "/home/apostolos/miniconda3/envs/forex/lib/python3.7/site-packages/pyls/python_ls.py", line 319, in m_text_document__completion
    return self.completions(textDocument['uri'], position)
  File "/home/apostolos/miniconda3/envs/forex/lib/python3.7/site-packages/pyls/python_ls.py", line 237, in completions
    completions = self._hook('pyls_completions', doc_uri, position=position)
  File "/home/apostolos/miniconda3/envs/forex/lib/python3.7/site-packages/pyls/python_ls.py", line 153, in _hook
    return hook_handlers(config=self.config, workspace=workspace, document=doc, **kwargs)
  File "/home/apostolos/miniconda3/envs/forex/lib/python3.7/site-packages/pluggy/hooks.py", line 286, in __call__
    return self._hookexec(self, self.get_hookimpls(), kwargs)
  File "/home/apostolos/miniconda3/envs/forex/lib/python3.7/site-packages/pluggy/manager.py", line 92, in _hookexec
    return self._inner_hookexec(hook, methods, kwargs)
  File "/home/apostolos/miniconda3/envs/forex/lib/python3.7/site-packages/pluggy/manager.py", line 335, in traced_hookexec
    return outcome.get_result()
  File "/home/apostolos/miniconda3/envs/forex/lib/python3.7/site-packages/pluggy/callers.py", line 80, in get_result
    raise ex[1].with_traceback(ex[2])
  File "/home/apostolos/miniconda3/envs/forex/lib/python3.7/site-packages/pluggy/callers.py", line 52, in from_call
    result = func()
  File "/home/apostolos/miniconda3/envs/forex/lib/python3.7/site-packages/pluggy/manager.py", line 333, in <lambda>
    outcome = _Result.from_call(lambda: oldcall(hook, hook_impls, kwargs))
  File "/home/apostolos/miniconda3/envs/forex/lib/python3.7/site-packages/pluggy/manager.py", line 86, in <lambda>
    firstresult=hook.spec.opts.get("firstresult") if hook.spec else False,
  File "/home/apostolos/miniconda3/envs/forex/lib/python3.7/site-packages/pluggy/callers.py", line 208, in _multicall
    return outcome.get_result()
  File "/home/apostolos/miniconda3/envs/forex/lib/python3.7/site-packages/pluggy/callers.py", line 80, in get_result
    raise ex[1].with_traceback(ex[2])
  File "/home/apostolos/miniconda3/envs/forex/lib/python3.7/site-packages/pluggy/callers.py", line 187, in _multicall
    res = hook_impl.function(*args)
  File "/home/apostolos/miniconda3/envs/forex/lib/python3.7/site-packages/pyls/plugins/jedi_completion.py", line 68, in pyls_completions
    return [_format_completion(d, include_params) for d in definitions] or None
  File "/home/apostolos/miniconda3/envs/forex/lib/python3.7/site-packages/pyls/plugins/jedi_completion.py", line 68, in <listcomp>
    return [_format_completion(d, include_params) for d in definitions] or None
  File "/home/apostolos/miniconda3/envs/forex/lib/python3.7/site-packages/pyls/plugins/jedi_completion.py", line 98, in _format_completion
    'documentation': _utils.format_docstring(d.docstring()),
  File "/home/apostolos/miniconda3/envs/forex/lib/python3.7/site-packages/jedi/api/classes.py", line 479, in docstring
    return super(Completion, self).docstring(raw=raw, fast=fast)
  File "/home/apostolos/miniconda3/envs/forex/lib/python3.7/site-packages/jedi/api/classes.py", line 242, in docstring
    return _Help(self._name).docstring(fast=fast, raw=raw)
  File "/home/apostolos/miniconda3/envs/forex/lib/python3.7/site-packages/jedi/api/classes.py", line 756, in docstring
    signature_text = _format_signatures(context)
  File "/home/apostolos/miniconda3/envs/forex/lib/python3.7/site-packages/jedi/api/classes.py", line 715, in _format_signatures
    for signature in context.get_signatures()
  File "/home/apostolos/miniconda3/envs/forex/lib/python3.7/site-packages/jedi/evaluate/context/klass.py", line 229, in get_signatures
    return [sig.bind(self) for sig in init_funcs.get_signatures()]
  File "/home/apostolos/miniconda3/envs/forex/lib/python3.7/site-packages/jedi/evaluate/context/klass.py", line 229, in <listcomp>
    return [sig.bind(self) for sig in init_funcs.get_signatures()]
  File "/home/apostolos/miniconda3/envs/forex/lib/python3.7/site-packages/jedi/evaluate/signature.py", line 107, in bind
    assert not self.is_bound

AssertionErrorWARNING:spyder.widgets.github.backend:Failed to send bug report on Github. response={'code': 401, 'json': {'message': 'Bad credentials', 'documentation_url': 'https://developer.github.com/v3'}}
```

## Versions

* Spyder version: 4.1.0.dev0 
* Python version: 3.7.3
* Qt version: 5.9.7
* PyQt5 version: 5.9.2
* Operating System: Linux 4.4.0-148-generic

### Dependencies

```
cloudpickle >=0.5.0          :  1.2.2 (OK)
pygments >=2.0               :  2.4.2 (OK)
qtconsole >=4.6.0            :  4.6.0 (OK)
nbconvert >=4.0              :  5.6.1 (OK)
sphinx >=0.6.6               :  2.2.2 (OK)
pylint >=0.25                :  2.4.4 (OK)
psutil >=0.3                 :  5.6.7 (OK)
qtawesome >=0.5.7            :  0.6.0 (OK)
qtpy >=1.5.0                 :  1.9.0 (OK)
pickleshare >=0.4            :  0.7.5 (OK)
zmq >=17                     :  18.1.0 (OK)
chardet >=2.0.0              :  3.0.4 (OK)
numpydoc >=0.6.0             :  0.9.1 (OK)
spyder_kernels >=1.8.1;<2.0.0:  1.8.1 (OK)
qdarkstyle >=2.7             :  2.7 (OK)
atomicwrites >=1.2.0         :  1.3.0 (OK)
diff_match_patch >=20181111  :  20181111 (OK)
intervaltree                 :  None (OK)
watchdog                     :  None (OK)
keyring                      :  None (OK)
pexpect >=4.4.0              :  4.7.0 (OK)
sympy >=0.7.3                :  1.4 (OK)
cython >=0.21                :  0.29.14 (OK)
IPython >=4.0                :  7.8.0 (OK)
matplotlib >=2.0.0           :  3.1.1 (OK)
pandas >=0.13.1              :  0.25.1 (OK)
numpy >=1.7                  :  1.17.2 (OK)
scipy >=0.17.0               :  1.3.1 (OK)
pyls >=0.31.2;<0.32.0        :  0.31.2 (OK)
xdg >=0.26                   :  0.26 (OK)
rtree >=0.8.3                :  0.9.3 (OK)
```



Discussion:
What's your Jedi version?
jedi==0.15.1
That's not among our requirements. We require `jedi==0.14.1` because completions are broken for scientific libraries with Jedi 0.15.
Thanks! It worked!

Resolving patch:
diff --git a/spyder/dependencies.py b/spyder/dependencies.py
--- a/spyder/dependencies.py
+++ b/spyder/dependencies.py
@@ -17,195 +17,241 @@
 from spyder.py3compat import PY2
 
 
+# =============================================================================
+# Versions
+# =============================================================================
+# Hard dependencies
+APPLAUNCHSERVICES_REQVER = '>=0.1.7'
+ATOMICWRITES_REQVER = '>=1.2.0'
+CHARDET_REQVER = '>=2.0.0'
 CLOUDPICKLE_REQVER = '>=0.5.0'
-PYGMENTS_REQVER = '>=2.0'
-QTCONSOLE_REQVER = '>=4.6.0'
+DIFF_MATCH_PATCH_REQVER = '>=20181111'
+INTERVALTREE_REQVER = None
+IPYTHON_REQVER = ">=4.0;<6.0" if PY2 else ">=4.0"
+JEDI_REQVER = '=0.14.1'
+KEYRING_REQVER = None
 NBCONVERT_REQVER = '>=4.0'
-SPHINX_REQVER = '>=0.6.6'
-PYLINT_REQVER = '>=0.25'
+NUMPYDOC_REQVER = '>=0.6.0'
+PARAMIKO_REQVER = '>=2.4.0'
+PEXPECT_REQVER = '>=4.4.0'
+PICKLESHARE_REQVER = '>=0.4'
 PSUTIL_REQVER = '>=0.3'
+PYGMENTS_REQVER = '>=2.0'
+PYLINT_REQVER = '>=0.25'
+PYLS_REQVER = '>=0.31.2;<0.32.0'
+PYXDG_REQVER = '>=0.26'
+PYZMQ_REQVER = '>=17'
+QDARKSTYLE_REQVER = '>=2.7'
 QTAWESOME_REQVER = '>=0.5.7'
+QTCONSOLE_REQVER = '>=4.6.0'
 QTPY_REQVER = '>=1.5.0'
-PICKLESHARE_REQVER = '>=0.4'
-PYZMQ_REQVER = '>=17'
-CHARDET_REQVER = '>=2.0.0'
-NUMPYDOC_REQVER = '>=0.6.0'
+RTREE_REQVER = '>=0.8.3'
+SPHINX_REQVER = '>=0.6.6'
 SPYDER_KERNELS_REQVER = '>=1.8.1;<2.0.0'
-QDARKSTYLE_REQVER = '>=2.7'
-ATOMICWRITES_REQVER = '>=1.2.0'
-DIFF_MATCH_PATCH_REQVER = '>=20181111'
 WATCHDOG_REQVER = None
-KEYRING_REQVER = None
-PEXPECT_REQVER = '>=4.4.0'
-PARAMIKO_REQVER = '>=2.4.0'
-PYXDG_REQVER = '>=0.26'
-RTREE_REQVER = '>=0.8.3'
-SYMPY_REQVER = '>=0.7.3'
+
+
+# Optional dependencies
 CYTHON_REQVER = '>=0.21'
-IPYTHON_REQVER = ">=4.0;<6.0" if PY2 else ">=4.0"
 MATPLOTLIB_REQVER = '>=2.0.0'
-PANDAS_REQVER = '>=0.13.1'
 NUMPY_REQVER = '>=1.7'
+PANDAS_REQVER = '>=0.13.1'
 SCIPY_REQVER = '>=0.17.0'
-PYLS_REQVER = '>=0.31.2;<0.32.0'
-APPLAUNCHSERVICES_REQVER = '>=0.1.7'
-INTERVALTREE_REQVER = None
+SYMPY_REQVER = '>=0.7.3'
 
 
-DEPENDENCIES_BASE = [
+# =============================================================================
+# Descriptions
+# NOTE: We declare our dependencies in **alphabetical** order
+# =============================================================================
+# List of descriptions
+DESCRIPTIONS = []
+
+if sys.platform == "darwin":
+    DESCRIPTIONS.append(
+        {'modname': "applaunchservices",
+         'package_name': "applaunchservices",
+         'features': _("Notify macOS that Spyder can open Python files"),
+         'required_version': APPLAUNCHSERVICES_REQVER})
+
+
+DESCRIPTIONS += [
+    {'modname': "atomicwrites",
+     'package_name': "atomicwrites",
+     'features': _("Atomic file writes in the Editor"),
+     'required_version': ATOMICWRITES_REQVER},
+    {'modname': "chardet",
+     'package_name': "chardet",
+     'features': _("Character encoding auto-detection for the Editor"),
+     'required_version': CHARDET_REQVER},
     {'modname': "cloudpickle",
      'package_name': "cloudpickle",
      'features': _("Handle communications between kernel and frontend"),
      'required_version': CLOUDPICKLE_REQVER},
-    {'modname': "pygments",
-     'package_name': "pygments",
-     'features': _("Syntax highlighting for a lot of file types in the Editor"),
-     'required_version': PYGMENTS_REQVER},
-    {'modname': "qtconsole",
-     'package_name': "qtconsole",
-     'features': _("Main package for the IPython console"),
-     'required_version': QTCONSOLE_REQVER},
+    {'modname': "diff_match_patch",
+     'package_name': "diff_match_patch",
+     'features': _("Compute text file diff changes during edition"),
+     'required_version': DIFF_MATCH_PATCH_REQVER},
+    {'modname': "intervaltree",
+     'package_name': "intervaltree",
+     'features': _("Compute folding range nesting levels"),
+     'required_version': INTERVALTREE_REQVER},
+    {'modname': "IPython",
+     'package_name': "IPython",
+     'features': _("IPython interactive python environment"),
+     'required_version': IPYTHON_REQVER},
+    {'modname': "jedi",
+     'package_name': "jedi",
+     'features': _("Main backend for the Python Language Server"),
+     'required_version': JEDI_REQVER},
+    {'modname': "keyring",
+     'package_name': "keyring",
+     'features': _("Save Github credentials to report internal errors securely"),
+     'required_version': KEYRING_REQVER},
     {'modname': "nbconvert",
      'package_name': "nbconvert",
      'features': _("Manipulate Jupyter notebooks in the Editor"),
      'required_version': NBCONVERT_REQVER},
-    {'modname': "sphinx",
-     'package_name': "sphinx",
-     'features': _("Show help for objects in the Editor and Consoles in a dedicated pane"),
-     'required_version': SPHINX_REQVER},
-    {'modname': "pylint",
-     'package_name': "pylint",
-     'features': _("Static code analysis"),
-     'required_version': PYLINT_REQVER},
+    {'modname': "numpydoc",
+     'package_name': "numpydoc",
+     'features': _("Improve code completion for objects that use Numpy docstrings"),
+     'required_version': NUMPYDOC_REQVER}
+]
+
+
+if sys.platform == 'nt':
+    DESCRIPTIONS.append(
+        {'modname': "paramiko",
+         'package_name': "paramiko",
+         'features': _("Connect to remote kernels through SSH"),
+         'required_version': PARAMIKO_REQVER}
+    )
+
+
+DESCRIPTIONS += [
+    {'modname': "pexpect",
+     'package_name': "pexpect",
+     'features': _("Stdio support for our language server client"),
+     'required_version': PEXPECT_REQVER},
+    {'modname': "pickleshare",
+     'package_name': "pickleshare",
+     'features': _("Cache the list of installed Python modules"),
+     'required_version': PICKLESHARE_REQVER},
     {'modname': "psutil",
      'package_name': "psutil",
      'features': _("CPU and memory usage info in the status bar"),
      'required_version': PSUTIL_REQVER},
+    {'modname': "pygments",
+     'package_name': "pygments",
+     'features': _("Syntax highlighting for a lot of file types in the Editor"),
+     'required_version': PYGMENTS_REQVER},
+    {'modname': "pylint",
+     'package_name': "pylint",
+     'features': _("Static code analysis"),
+     'required_version': PYLINT_REQVER},
+    {'modname': 'pyls',
+     'package_name': 'python-language-server',
+     'features': _("Code completion and linting for the Editor"),
+     'required_version': PYLS_REQVER}
+]
+
+
+if sys.platform.startswith('linux'):
+    DESCRIPTIONS.append(
+        {'modname': "xdg",
+         'package_name': "pyxdg",
+         'features': _("Parse desktop files on Linux"),
+         'required_version': PYXDG_REQVER}
+    )
+
+
+DESCRIPTIONS += [
+    {'modname': "zmq",
+     'package_name': "pyzmq",
+     'features': _("Client for the language server protocol (LSP)"),
+     'required_version': PYZMQ_REQVER},
+    {'modname': "qdarkstyle",
+     'package_name': "qdarkstyle",
+     'features': _("Dark style for the entire interface"),
+     'required_version': QDARKSTYLE_REQVER},
     {'modname': "qtawesome",
      'package_name': "qtawesome",
      'features': _("Icon theme based on FontAwesome and Material Design icons"),
      'required_version': QTAWESOME_REQVER},
+    {'modname': "qtconsole",
+     'package_name': "qtconsole",
+     'features': _("Main package for the IPython console"),
+     'required_version': QTCONSOLE_REQVER},
     {'modname': "qtpy",
      'package_name': "qtpy",
      'features': _("Abstraction layer for Python Qt bindings."),
-     'required_version': QTPY_REQVER},
-    {'modname': "pickleshare",
-     'package_name': "pickleshare",
-     'features': _("Cache the list of installed Python modules"),
-     'required_version': PICKLESHARE_REQVER},
-    {'modname': "zmq",
-     'package_name': "pyzmq",
-     'features': _("Client for the language server protocol (LSP)"),
-     'required_version': PYZMQ_REQVER},
-    {'modname': "chardet",
-     'package_name': "chardet",
-     'features': _("Character encoding auto-detection for the Editor"),
-     'required_version': CHARDET_REQVER},
-    {'modname': "numpydoc",
-     'package_name': "numpydoc",
-     'features': _("Improve code completion for objects that use Numpy docstrings"),
-     'required_version': NUMPYDOC_REQVER},
+     'required_version': QTPY_REQVER}
+]
+
+
+if is_anaconda():
+    DESCRIPTIONS.append(
+        {'modname': "rtree",
+         'package_name': "rtree",
+         'features': _("Fast access to code snippets regions"),
+         'required_version': RTREE_REQVER}
+    )
+
+
+DESCRIPTIONS += [
+    {'modname': "sphinx",
+     'package_name': "sphinx",
+     'features': _("Show help for objects in the Editor and Consoles in a dedicated pane"),
+     'required_version': SPHINX_REQVER},
     {'modname': "spyder_kernels",
      'package_name': "spyder-kernels",
      'features': _("Jupyter kernels for the Spyder console"),
      'required_version': SPYDER_KERNELS_REQVER},
-    {'modname': "qdarkstyle",
-     'package_name': "qdarkstyle",
-     'features': _("Dark style for the entire interface"),
-     'required_version': QDARKSTYLE_REQVER},
-    {'modname': "atomicwrites",
-     'package_name': "atomicwrites",
-     'features': _("Atomic file writes in the Editor"),
-     'required_version': ATOMICWRITES_REQVER},
-    {'modname': "diff_match_patch",
-     'package_name': "diff_match_patch",
-     'features': _("Compute text file diff changes during edition"),
-     'required_version': DIFF_MATCH_PATCH_REQVER},
-    {'modname': "intervaltree",
-     'package_name': "intervaltree",
-     'features': _("Compute folding range nesting levels"),
-     'required_version': INTERVALTREE_REQVER},
     {'modname': "watchdog",
      'package_name': "watchdog",
      'features': _("Watch file changes on project directories"),
-     'required_version': WATCHDOG_REQVER},
-    {'modname': "keyring",
-     'package_name': "keyring",
-     'features': _("Save Github credentials to report internal errors securely"),
-     'required_version': KEYRING_REQVER},
-    {'modname': "pexpect",
-     'package_name': "pexpect",
-     'features': _("Stdio support for our language server client"),
-     'required_version': PEXPECT_REQVER},
-    {'modname': "sympy",
-     'package_name': "sympy",
-     'features': _("Symbolic mathematics in the IPython Console"),
-     'required_version': SYMPY_REQVER,
-     'optional': True},
+     'required_version': WATCHDOG_REQVER}
+]
+
+
+# Optional dependencies
+DESCRIPTIONS += [
     {'modname': "cython",
      'package_name': "cython",
      'features': _("Run Cython files in the IPython Console"),
      'required_version': CYTHON_REQVER,
      'optional': True},
-    {'modname': "IPython",
-     'package_name': "IPython",
-     'features': _("IPython interactive python environment"),
-     'required_version': IPYTHON_REQVER},
     {'modname': "matplotlib",
      'package_name': "matplotlib",
      'features': _("2D/3D plotting in the IPython console"),
      'required_version': MATPLOTLIB_REQVER,
      'optional': True},
-    {'modname': 'pandas',
-     'package_name':  'pandas',
-     'features': _("View and edit DataFrames and Series in the Variable Explorer"),
-     'required_version': PANDAS_REQVER,
-     'optional': True},
     {'modname': "numpy",
      'package_name': "numpy",
      'features': _("View and edit two and three dimensional arrays in the Variable Explorer"),
      'required_version': NUMPY_REQVER,
      'optional': True},
+    {'modname': 'pandas',
+     'package_name':  'pandas',
+     'features': _("View and edit DataFrames and Series in the Variable Explorer"),
+     'required_version': PANDAS_REQVER,
+     'optional': True},
     {'modname': "scipy",
      'package_name': "scipy",
      'features': _("Import Matlab workspace files in the Variable Explorer"),
      'required_version': SCIPY_REQVER,
      'optional': True},
-    {'modname': 'pyls',
-     'package_name': 'python-language-server',
-     'features': _("Code completion and linting for the Editor"),
-     'required_version': PYLS_REQVER}]
-
-if sys.platform == "darwin":
-    DEPENDENCIES_BASE.append(
-        {'modname': "applaunchservices",
-         'package_name': "applaunchservices",
-         'features': _("Notify macOS that Spyder can open Python files"),
-         'required_version': APPLAUNCHSERVICES_REQVER})
-
-if sys.platform.startswith('linux'):
-    DEPENDENCIES_BASE.append(
-        {'modname': "xdg",
-         'package_name': "pyxdg",
-         'features': _("Parse desktop files on Linux"),
-         'required_version': PYXDG_REQVER})
-
-if sys.platform == 'nt':
-    DEPENDENCIES_BASE.append(
-        {'modname': "paramiko",
-         'package_name': "paramiko",
-         'features': _("Connect to remote kernels through SSH"),
-         'required_version': PARAMIKO_REQVER})
-
-if is_anaconda():
-    DEPENDENCIES_BASE.append(
-        {'modname': "rtree",
-         'package_name': "rtree",
-         'features': _("Fast access to code snippets regions"),
-         'required_version': RTREE_REQVER}
-    )
+    {'modname': "sympy",
+     'package_name': "sympy",
+     'features': _("Symbolic mathematics in the IPython Console"),
+     'required_version': SYMPY_REQVER,
+     'optional': True}
+]
 
 
+# =============================================================================
+# Code
+# =============================================================================
 class Dependency(object):
     """Spyder's dependency
 
@@ -317,7 +363,7 @@ def missing_dependencies():
 
 
 def declare_dependencies():
-    for dep in DEPENDENCIES_BASE:
+    for dep in DESCRIPTIONS:
         # Detect if dependency is optional
         if dep.get('optional', False):
             optional = True


Test patch: