jorgenschaefer / elpy

Emacs Python Development Environment
GNU General Public License v3.0
1.9k stars 260 forks source link

jedi: ValueError: Node(…) is not in list #820

Closed joostkremers closed 6 years ago

joostkremers commented 8 years ago

Emacs just popped up this buffer while I was trying to get a variable name to complete.

There was really only one way to complete the variable in question, and company was already showing it. I typed TAB to have it completed, though I should of course have typed RET, which I typed right afterward. Around that moment, the buffer popped up. (Can't really say whether it was before or after typing RET, though.)

Error Message

Node(simple_stmt, [<ExprStmt: locations = {0: "You are sitting in front of a computer learning Python",              1: "You are standing at the end of a road before a small brick building",              2: "You are at the top of a hill",              3: "You are inside a building, a well house for a small stream",              4: "You are in a valley beside a stream",              5: "You are in the forest"}@1,0>, <Whitespace: 
>]) is not in list

Configuration

Virtualenv........: Udemy (/home/joost/src/Python/Environments/Udemy)
RPC Python........: 3.4.3 (/home/joost/src/Python/Environments/Udemy/bin/python)
Interactive Python: ipython (/home/joost/src/Python/Environments/Udemy/bin/ipython)
Emacs.............: 25.0.92.1
Elpy..............: 1.11.0
Jedi..............: 0.9.0
Rope..............: Not found (0.10.3 available)
Importmagic.......: 0.1.3
Autopep8..........: 1.2.2
Yapf..............: 0.6.2
Syntax checker....: flake8 (/home/joost/src/Python/Environments/Udemy/bin/flake8)

Traceback

Traceback (most recent call last):
  File "/home/joost/src/Python/Environments/Udemy/lib/python3.4/site-packages/jedi/api/classes.py", line 722, in full
    return self._name.doc
AttributeError: 'ExprStmt' object has no attribute 'doc'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/home/joost/.elpa/elpy-20160131.118/elpy/rpc.py", line 100, in handle_request
    result = method(*params)
  File "/home/joost/.elpa/elpy-20160131.118/elpy/server.py", line 107, in rpc_get_completion_docstring
    None, completion)
  File "/home/joost/.elpa/elpy-20160131.118/elpy/server.py", line 50, in _call_backend
    return meth(*args, **kwargs)
  File "/home/joost/.elpa/elpy-20160131.118/elpy/jedibackend.py", line 52, in rpc_get_completion_docstring
    return proposal.docstring(fast=False)
  File "/home/joost/src/Python/Environments/Udemy/lib/python3.4/site-packages/jedi/api/classes.py", line 457, in docstring
    return _Help(definition).full()
  File "/home/joost/src/Python/Environments/Udemy/lib/python3.4/site-packages/jedi/api/classes.py", line 724, in full
    return self.raw()
  File "/home/joost/src/Python/Environments/Udemy/lib/python3.4/site-packages/jedi/api/classes.py", line 733, in raw
    return self._name.raw_doc
  File "/home/joost/src/Python/Environments/Udemy/lib/python3.4/site-packages/jedi/parser/tree.py", line 75, in raw_doc
    index = c.index(simple_stmt)
ValueError: Node(simple_stmt, [<ExprStmt: locations = {0: "You are sitting in front of a computer learning Python",              1: "You are standing at the end of a road before a small brick building",              2: "You are at the top of a hill",              3: "You are inside a building, a well house for a small stream",              4: "You are in a valley beside a stream",              5: "You are in the forest"}@1,0>, <Whitespace: 
>]) is not in list
jorgenschaefer commented 8 years ago

Thank you for the report! Apparently, Elpy was trying to get the docstring of the symbol you were trying to complete (did you type C-c C-d perchance?), and there is a bug in Jedi in this case. I reported this problem upstream.

joostkremers commented 8 years ago

I might have accidentally typed C-c C-d, though I can't be sure. (I'm not entirely sure anymore what I did and what happened and in what sequence everything transpired. Normally, I wouldn't have opened an issue, but since Emacs kindly asked me to, I posted it anyway.)

If this looks like an instance of a known upstream bug, you can probably close this issue.

Thanks for the quick response, and for elpy!

jorgenschaefer commented 8 years ago

You are always welcome and encouraged to open issues with Elpy if you have any problems, questions, or anything. :-)

And this looks like a new issue for upstream, too! So excellent to have this reported.