Skip to content

Error when running python-lsp-server with Electron+monaco editor: ERROR pylsp_jsonrpc.endpoint - Failed to handle request  #119

Closed
@pplonski

Description

@pplonski

I'm working on an example of the Electron app with monaco-editor and full Python completion. I'm using python-lsp-server. My repo is available at: https://github.com/pplonski/electron-monaco-python-lsp

I'm getting the following error in pylsp:

JSON Server: 2021-11-23 09:45:09,904 CET - ERROR - pylsp_jsonrpc.endpoint - Failed to handle request 42
Traceback (most recent call last):
  File "/home/piotr/sandbox/example/pyls/venv/lib/python3.8/site-packages/pylsp/plugins/jedi_completion.py", line 311, in resolve_label
    sig = completion.get_signatures()
  File "/home/piotr/sandbox/example/pyls/venv/lib/python3.8/site-packages/jedi/api/classes.py", line 582, in get_signatures
    for s in self._get_signatures()
  File "/home/piotr/sandbox/example/pyls/venv/lib/python3.8/site-packages/jedi/api/classes.py", line 570, in _get_signatures
    names = convert_names([self._name], prefer_stubs=True)
  File "/home/piotr/sandbox/example/pyls/venv/lib/python3.8/site-packages/jedi/inference/gradual/conversion.py", line 152, in convert_names
    return _python_to_stub_names(names, fallback_to_python=prefer_stubs)
  File "/home/piotr/sandbox/example/pyls/venv/lib/python3.8/site-packages/jedi/inference/utils.py", line 16, in wrapper
    return list(func(*args, **kwargs))
  File "/home/piotr/sandbox/example/pyls/venv/lib/python3.8/site-packages/jedi/inference/gradual/conversion.py", line 126, in _python_to_stub_names
    for x in _python_to_stub_names([n], fallback_to_python=fallback_to_python):
  File "/home/piotr/sandbox/example/pyls/venv/lib/python3.8/site-packages/jedi/inference/utils.py", line 16, in wrapper
    return list(func(*args, **kwargs))
  File "/home/piotr/sandbox/example/pyls/venv/lib/python3.8/site-packages/jedi/inference/gradual/conversion.py", line 132, in _python_to_stub_names
    v = name.get_defining_qualified_value()
  File "/home/piotr/sandbox/example/pyls/venv/lib/python3.8/site-packages/jedi/inference/names.py", line 251, in get_defining_qualified_value
    if context.is_module() or context.is_class():
AttributeError: 'NoneType' object has no attribute 'is_module'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/home/piotr/sandbox/example/pyls/venv/lib/python3.8/site-packages/pylsp_jsonrpc/endpoint.py", line 116, in consume
    self._handle_request(message['id'], message['method'], message.get('params'))
  File "/home/piotr/sandbox/example/pyls/venv/lib/python3.8/site-packages/pylsp_jsonrpc/endpoint.py", line 185, in _handle_request
    handler_result = handler(params)
  File "/home/piotr/sandbox/example/pyls/venv/lib/python3.8/site-packages/pylsp_jsonrpc/dispatchers.py", line 25, in handler
    return method(**(params or {}))
  File "/home/piotr/sandbox/example/pyls/venv/lib/python3.8/site-packages/pylsp/python_lsp.py", line 350, in m_text_document__completion
    return self.completions(textDocument['uri'], position)
  File "/home/piotr/sandbox/example/pyls/venv/lib/python3.8/site-packages/pylsp/python_lsp.py", line 261, in completions
    completions = self._hook('pylsp_completions', doc_uri, position=position)
  File "/home/piotr/sandbox/example/pyls/venv/lib/python3.8/site-packages/pylsp/python_lsp.py", line 156, in _hook
    return hook_handlers(config=self.config, workspace=workspace, document=doc, **kwargs)
  File "/home/piotr/sandbox/example/pyls/venv/lib/python3.8/site-packages/pluggy/_hooks.py", line 265, in __call__
    return self._hookexec(self.name, self.get_hookimpls(), kwargs, firstresult)
  File "/home/piotr/sandbox/example/pyls/venv/lib/python3.8/site-packages/pluggy/_manager.py", line 80, in _hookexec
    return self._inner_hookexec(hook_name, methods, kwargs, firstresult)
  File "/home/piotr/sandbox/example/pyls/venv/lib/python3.8/site-packages/pluggy/_manager.py", line 327, in traced_hookexec
    return outcome.get_result()
  File "/home/piotr/sandbox/example/pyls/venv/lib/python3.8/site-packages/pluggy/_result.py", line 60, in get_result
    raise ex[1].with_traceback(ex[2])
  File "/home/piotr/sandbox/example/pyls/venv/lib/python3.8/site-packages/pluggy/_result.py", line 33, in from_call
    result = func()
  File "/home/piotr/sandbox/example/pyls/venv/lib/python3.8/site-packages/pluggy/_manager.py", line 324, in <lambda>
    lambda: oldcall(hook_name, hook_impls, kwargs, firstresult)
  File "/home/piotr/sandbox/example/pyls/venv/lib/python3.8/site-packages/pluggy/_callers.py", line 60, in _multicall
    return outcome.get_result()
  File "/home/piotr/sandbox/example/pyls/venv/lib/python3.8/site-packages/pluggy/_result.py", line 60, in get_result
    raise ex[1].with_traceback(ex[2])
  File "/home/piotr/sandbox/example/pyls/venv/lib/python3.8/site-packages/pluggy/_callers.py", line 39, in _multicall
    res = hook_impl.function(*args)
  File "/home/piotr/sandbox/example/pyls/venv/lib/python3.8/site-packages/pylsp/plugins/jedi_completion.py", line 68, in pylsp_completions
    ready_completions = [
  File "/home/piotr/sandbox/example/pyls/venv/lib/python3.8/site-packages/pylsp/plugins/jedi_completion.py", line 69, in <listcomp>
    _format_completion(
  File "/home/piotr/sandbox/example/pyls/venv/lib/python3.8/site-packages/pylsp/plugins/jedi_completion.py", line 180, in _format_completion
    'label': _label(d, resolve_label),
  File "/home/piotr/sandbox/example/pyls/venv/lib/python3.8/site-packages/pylsp/plugins/jedi_completion.py", line 226, in _label
    sig = LABEL_RESOLVER.get_or_create(definition)
  File "/home/piotr/sandbox/example/pyls/venv/lib/python3.8/site-packages/pylsp/plugins/jedi_completion.py", line 296, in get_or_create
    self._cache[key] = self.resolve_label(completion)
  File "/home/piotr/sandbox/example/pyls/venv/lib/python3.8/site-packages/pylsp/plugins/jedi_completion.py", line 314, in resolve_label
    log.warning(
  File "/usr/lib/python3.8/logging/__init__.py", line 1458, in warning
    self._log(WARNING, msg, args, **kwargs)
TypeError: _log() got an unexpected keyword argument 'completion'

Reproduce steps

  1. Install:
pip install python-lsp-server
pip install python-lsp-server[yapf]
pip install numpy
  1. Run electron app and write:
import numpy
numpy.random.

After the last dot the exception will be thrown.

In the Electron app I get:

Error
TypeError: _log() got an unexpected keyword argument 'completion'

Error: TypeError: _log() got an unexpected keyword argument 'completion'
at handleResponse (http://localhost:1212/renderer.dev.js:240484:48)
at processMessageQueue (http://localhost:1212/renderer.dev.js:240299:17)
at http://localhost:1212/renderer.dev.js:240283:13

Is this issue related to python-lsp-server or rather to my settings and client code in Electron?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions