Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Yet Another Jedi Exception : ) #223

Open
liavkoren opened this issue Nov 14, 2017 · 5 comments
Open

Yet Another Jedi Exception : ) #223

liavkoren opened this issue Nov 14, 2017 · 5 comments

Comments

@liavkoren
Copy link

In [1]: import numpy as np
In [2]: a = np.array([1])
In [3]: b = np.array([2])
In [4]: (a - b > 0).Exception in thread Thread-457:

Traceback (most recent call last):
  File "/usr/local/Cellar/python3/3.6.0/Frameworks/Python.framework/Versions/3.6/lib/python3.6/threading.py", line 916, in _bootstrap_inner
    self.run()
  File "/usr/local/Cellar/python3/3.6.0/Frameworks/Python.framework/Versions/3.6/lib/python3.6/threading.py", line 864, in run
    self._target(*self._args, **self._kwargs)
  File "/usr/local/Cellar/python3/3.6.0/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/prompt_toolkit/interface.py", line 860, in run                              [F2] Menu - CPython 3.6.0
    completions = list(buffer.completer.get_completions(document, complete_event))
  File "/usr/local/Cellar/python3/3.6.0/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/prompt_toolkit/contrib/regular_languages/completion.py", line 37, in get_completions
    self._get_completions_for_match(m, complete_event))
  File "/usr/local/Cellar/python3/3.6.0/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/prompt_toolkit/contrib/regular_languages/completion.py", line 81, in _remove_duplicates
    for i in items:
  File "/usr/local/Cellar/python3/3.6.0/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/prompt_toolkit/contrib/regular_languages/completion.py", line 64, in _get_completions_for_match
    for completion in completer.get_completions(document, complete_event):
  File "/usr/local/Cellar/python3/3.6.0/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/ptpython/completer.py", line 127, in get_completions
    completions = script.completions()
  File "/usr/local/lib/python2.7/site-packages/jedi/api/__init__.py", line 188, in completions
    completion_names = get_completions(user_stmt, b)
  File "/usr/local/lib/python2.7/site-packages/jedi/api/__init__.py", line 174, in get_completions
    completion_names += self._simple_complete(path, dot, like)
  File "/usr/local/lib/python2.7/site-packages/jedi/api/__init__.py", line 604, in _simple_complete
    return super(Interpreter, self)._simple_complete(path, dot, like)
  File "/usr/local/lib/python2.7/site-packages/jedi/api/__init__.py", line 250, in _simple_complete
    scopes = list(self._prepare_goto(path, True))
  File "/usr/local/lib/python2.7/site-packages/jedi/api/__init__.py", line 294, in _prepare_goto
    scopes = self._evaluator.eval_element(eval_stmt)
  File "/usr/local/lib/python2.7/site-packages/jedi/evaluate/cache.py", line 41, in wrapper
    rv = function(obj, *args, **kwargs)
  File "/usr/local/lib/python2.7/site-packages/jedi/evaluate/__init__.py", line 169, in eval_element
    return self._eval_atom(element)
  File "/usr/local/lib/python2.7/site-packages/jedi/evaluate/__init__.py", line 239, in _eval_atom
    return self.eval_element(c[1])
  File "/usr/local/lib/python2.7/site-packages/jedi/evaluate/cache.py", line 41, in wrapper
    rv = function(obj, *args, **kwargs)
  File "/usr/local/lib/python2.7/site-packages/jedi/evaluate/__init__.py", line 212, in eval_element
    return precedence.calculate_children(self, element.children)
  File "/usr/local/lib/python2.7/site-packages/jedi/evaluate/precedence.py", line 61, in calculate_children
    evaluator.eval_element(right))
  File "/usr/local/lib/python2.7/site-packages/jedi/evaluate/precedence.py", line 81, in calculate
    result += _element_calculate(evaluator, left, operator, right)
  File "/usr/local/lib/python2.7/site-packages/jedi/evaluate/precedence.py", line 156, in _element_calculate
    return [keyword_from_value(operation(left, right))]
  File "/usr/local/lib/python2.7/site-packages/jedi/evaluate/compiled/__init__.py", line 495, in keyword_from_value
    raise NotImplementedError
NotImplementedError

Note: the exception happens immediately on typing the period in (a - b > 0).

numpy==1.10.4
prompt-toolkit==1.0.15
jedi==0.11.0

I deeply love ptipython (it's my default python repl) and, you know, god[s]/time-management willing, I'm happy to try and help.

It's not super rare for me to run into Jedi exceptions. Overall, those aren't actually a big deal, but what is kind of a drag is then not having access to autocomplete for the rest of the life-span of the parent ptpython session. I'm assuming Jedi is being run in a child thread, and when it hits an unhandled exception, it takes autocomplete out. How much of a PITA would it be for a new Jedi to be created when that happens?

@jonathanslenders
Copy link
Member

Hi @liavkoren
Thanks for opening this issue!
The Jedi completion runs indeed in another thread.
Would the following fix work: #224 ?

It's not the cleanest solution, but otherwise I have to keep adding exceptions for everything that Jedi will throw.

@liavkoren
Copy link
Author

Oh, just saw this. Would you like me to pull the commit and check it locally?

@liavkoren
Copy link
Author

Okay, I'm tots confused. I cloned the repo and pip installed -e, but I can't reproduce the jedi error even on master. Numpy, prompt-toolkit and jedi versions all match.

@jonathanslenders
Copy link
Member

Ok. No problem. I'll probably merge it anyway. These Jedi errors are pretty annoying, and right now, I don't have a good way to log what's going wrong without disturbing the end user.

@liavkoren
Copy link
Author

Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants