question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

KeyError in PyLS when getting a hover

See original GitHub issue

Description

What steps will reproduce the problem?

I have code that uses Argparse (which I am practicing). When I open Spyder, I run the file. Then I select a variable in the editor, and this error keeps popping up as soon as it is highlighted by Spyder. I restarted Spyder, and the issue seems to persist.

Traceback

  File "/home/parichay/code/spyderz/spyder4/lib/python3.5/site-packages/pyls_jsonrpc/endpoint.py", line 113, in consume
    self._handle_request(message['id'], message['method'], message.get('params'))
  File "/home/parichay/code/spyderz/spyder4/lib/python3.5/site-packages/pyls_jsonrpc/endpoint.py", line 182, in _handle_request
    handler_result = handler(params)
  File "/home/parichay/code/spyderz/spyder4/lib/python3.5/site-packages/pyls_jsonrpc/dispatchers.py", line 23, in handler
    return method(**(params or {}))
  File "/home/parichay/code/spyderz/spyder4/lib/python3.5/site-packages/pyls/python_ls.py", line 271, in m_text_document__hover
    return self.hover(textDocument['uri'], position)
  File "/home/parichay/code/spyderz/spyder4/lib/python3.5/site-packages/pyls/python_ls.py", line 215, in hover
    return self._hook('pyls_hover', doc_uri, position=position) or {'contents': ''}
  File "/home/parichay/code/spyderz/spyder4/lib/python3.5/site-packages/pyls/python_ls.py", line 122, in _hook
    return hook_handlers(config=self.config, workspace=self.workspace, document=doc, **kwargs)
  File "/home/parichay/code/spyderz/spyder4/lib/python3.5/site-packages/pluggy/hooks.py", line 289, in __call__
    return self._hookexec(self, self.get_hookimpls(), kwargs)
  File "/home/parichay/code/spyderz/spyder4/lib/python3.5/site-packages/pluggy/manager.py", line 68, in _hookexec
    return self._inner_hookexec(hook, methods, kwargs)
  File "/home/parichay/code/spyderz/spyder4/lib/python3.5/site-packages/pluggy/_tracing.py", line 80, in __call__
    return outcome.get_result()
  File "/home/parichay/code/spyderz/spyder4/lib/python3.5/site-packages/pluggy/callers.py", line 80, in get_result
    raise ex[1].with_traceback(ex[2])
  File "/home/parichay/code/spyderz/spyder4/lib/python3.5/site-packages/pluggy/callers.py", line 52, in from_call
    result = func()
  File "/home/parichay/code/spyderz/spyder4/lib/python3.5/site-packages/pluggy/_tracing.py", line 78, in <lambda>
    outcome = _Result.from_call(lambda: self.oldcall(hook, hook_impls, kwargs))
  File "/home/parichay/code/spyderz/spyder4/lib/python3.5/site-packages/pluggy/manager.py", line 62, in <lambda>
    firstresult=hook.spec.opts.get("firstresult") if hook.spec else False,
  File "/home/parichay/code/spyderz/spyder4/lib/python3.5/site-packages/pluggy/callers.py", line 208, in _multicall
    return outcome.get_result()
  File "/home/parichay/code/spyderz/spyder4/lib/python3.5/site-packages/pluggy/callers.py", line 80, in get_result
    raise ex[1].with_traceback(ex[2])
  File "/home/parichay/code/spyderz/spyder4/lib/python3.5/site-packages/pluggy/callers.py", line 187, in _multicall
    res = hook_impl.function(*args)
  File "/home/parichay/code/spyderz/spyder4/lib/python3.5/site-packages/pyls/plugins/hover.py", line 10, in pyls_hover
    definitions = document.jedi_script(position).goto_definitions()
  File "/home/parichay/code/spyderz/spyder4/lib/python3.5/site-packages/jedi/api/__init__.py", line 220, in goto_definitions
    definitions = helpers.evaluate_goto_definition(self._evaluator, context, leaf)
  File "/home/parichay/code/spyderz/spyder4/lib/python3.5/site-packages/jedi/api/helpers.py", line 143, in evaluate_goto_definition
    return evaluator.goto_definitions(context, leaf)
  File "/home/parichay/code/spyderz/spyder4/lib/python3.5/site-packages/jedi/evaluate/__init__.py", line 230, in goto_definitions
    return eval_expr_stmt(context, def_, name)
  File "/home/parichay/code/spyderz/spyder4/lib/python3.5/site-packages/jedi/evaluate/syntax_tree.py", line 48, in wrapper
    return func(context, *args, **kwargs)
  File "/home/parichay/code/spyderz/spyder4/lib/python3.5/site-packages/jedi/evaluate/syntax_tree.py", line 284, in eval_expr_stmt
    return _eval_expr_stmt(context, stmt, seek_name)
  File "/home/parichay/code/spyderz/spyder4/lib/python3.5/site-packages/jedi/debug.py", line 81, in wrapper
    return func(*args, **kwargs)
  File "/home/parichay/code/spyderz/spyder4/lib/python3.5/site-packages/jedi/evaluate/syntax_tree.py", line 300, in _eval_expr_stmt
    context_set = context.eval_node(rhs)
  File "/home/parichay/code/spyderz/spyder4/lib/python3.5/site-packages/jedi/evaluate/base_context.py", line 145, in eval_node
    return self.evaluator.eval_element(self, node)
  File "/home/parichay/code/spyderz/spyder4/lib/python3.5/site-packages/jedi/evaluate/__init__.py", line 200, in eval_element
    return self._eval_element_if_evaluated(context, element)
  File "/home/parichay/code/spyderz/spyder4/lib/python3.5/site-packages/jedi/evaluate/__init__.py", line 212, in _eval_element_if_evaluated
    return self._eval_element_cached(context, element)
  File "/home/parichay/code/spyderz/spyder4/lib/python3.5/site-packages/jedi/evaluate/cache.py", line 40, in wrapper
    rv = function(obj, *args, **kwargs)
  File "/home/parichay/code/spyderz/spyder4/lib/python3.5/site-packages/jedi/evaluate/__init__.py", line 216, in _eval_element_cached
    return eval_node(context, element)
  File "/home/parichay/code/spyderz/spyder4/lib/python3.5/site-packages/jedi/debug.py", line 81, in wrapper
    return func(*args, **kwargs)
  File "/home/parichay/code/spyderz/spyder4/lib/python3.5/site-packages/jedi/evaluate/syntax_tree.py", line 48, in wrapper
    return func(context, *args, **kwargs)
  File "/home/parichay/code/spyderz/spyder4/lib/python3.5/site-packages/jedi/evaluate/syntax_tree.py", line 85, in eval_node
    context_set = eval_atom(context, first_child)
  File "/home/parichay/code/spyderz/spyder4/lib/python3.5/site-packages/jedi/evaluate/syntax_tree.py", line 262, in eval_atom
    context = iterable.SequenceLiteralContext(context.evaluator, context, atom)
  File "/home/parichay/code/spyderz/spyder4/lib/python3.5/site-packages/jedi/evaluate/context/iterable.py", line 293, in __init__
    self.array_type = SequenceLiteralContext.mapping[atom.children[0]]

Versions

  • Spyder version: 4.0.0b2
  • Python version: 3.5.2
  • Qt version: 5.12.3
  • PyQt5 version: 5.12.2
  • Operating System: Linux 4.4.0-148-generic

Dependencies

pygments >=2.0     :  2.4.0 (OK)
qdarkstyle >=2.6.4 :  2.6.8 (OK)
sphinx >=0.6.6     :  2.0.1 (OK)
psutil >=0.3       :  5.6.2 (OK)
pyls >=0.19.0;<0.25:  0.24.0 (OK)
nbconvert >=4.0    :  5.5.0 (OK)
pandas >=0.13.1    :  None (NOK)
numpy >=1.7        :  None (NOK)
sympy >=0.7.3      :  None (NOK)
cython >=0.21      :  None (NOK)
qtconsole >=4.2.0  :  4.4.4 (OK)
IPython >=4.0      :  7.5.0 (OK)
matplotlib >=2.0.0 :  None (NOK)
pylint >=0.25      :  2.3.1 (OK)

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:10 (5 by maintainers)

github_iconTop GitHub Comments

2reactions
ccordoba12commented, Jun 10, 2019

Thanks a lot for the video! I was able to reproduce the error and now I know how to solve it.

0reactions
ccordoba12commented, Aug 25, 2019

Please run

pip install jedi==0.14.1 python-language-server==0.28.1

to fix this.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Error with textDocument/hover · Issue #136 - GitHub
The error occurs when hovering over a symbol. LSP: request 13: textDocument/hover LSP: (stderr): b'2017-09-13 21:44:08255 U...
Read more >
Python KeyError Exceptions and How to Handle Them
In this tutorial, you'll learn how to handle Python KeyError exceptions. They are often caused by a bad key lookup in a dictionary,...
Read more >
Getting started with lsp-mode for Python - Matt Duck
I have used pyls . You have two options for installing pyls and its dependencies: pip install python-language-server[all] . This will ...
Read more >
KeyError when trying to access ['style'] using Beautiful Soup
I'm trying to access the style of a DIV element on a page using Beautiful Soup 4 but I keep getting a key...
Read more >
Fun things to do with Graph configurations in Dash
By default, the Mode Bar shows a tiny Plotly icon, which shows 'Produced with Plotly' when hovering over it and link to the...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found