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

deferred error : (error ""AttributeError("'Definition' object has no attribute 'get_code' ",)"") #293

Open
sdilts opened this Issue Sep 28, 2017 · 12 comments

Comments

Projects
None yet
5 participants
@sdilts

sdilts commented Sep 28, 2017

This error occurs whenever a functions signature is grabbed with jedi:get-in-function-call, and originates at line 103:

params=[p.get_code().replace('\n', '') for p in call_def.params],

This prevents jedi-mode from doing any sort of function signature completion.

Package version is 20160425.2156. The relevant code in my .emacs file is

 (require 'jedi)                                                                                                                                                                                                   
 (setf jedi:complete-on-dot t)                                                                                                                        
 (unless (jedi:-env-server-command)                                                                                
      (jedi:install-server)))

I have uninstalled/reinstalled jedi-mode through the package manager several times, as well removing the server manually deleting the installation folder. The server has then always been reinstalled with jedi:install-server.

@sdilts sdilts changed the title from deferred error : (error "\"AttributeError(\\\"'Definition' object has no attribute 'get_code'\\\",)\"") to deferred error : (error ""AttributeError("'Definition' object has no attribute 'get_code' ",)"") Sep 28, 2017

@albertodonato

This comment has been minimized.

Show comment
Hide comment
@albertodonato

albertodonato Oct 12, 2017

I have a similar AttributeError, on a different attribute: (error "\"AttributeError(\\\"'module' object has no attribute 'defined_names'\\\",)\"")

I have the following package versions in my virtualenv:

$ pip freeze
epc==0.0.5
jedi==0.11.0
jediepcserver==0.2.7
parso==0.1.0
pkg-resources==0.0.0
sexpdata==0.0.3

and jedi version 20160425.2156

albertodonato commented Oct 12, 2017

I have a similar AttributeError, on a different attribute: (error "\"AttributeError(\\\"'module' object has no attribute 'defined_names'\\\",)\"")

I have the following package versions in my virtualenv:

$ pip freeze
epc==0.0.5
jedi==0.11.0
jediepcserver==0.2.7
parso==0.1.0
pkg-resources==0.0.0
sexpdata==0.0.3

and jedi version 20160425.2156

@sdilts

This comment has been minimized.

Show comment
Hide comment
@sdilts

sdilts Oct 12, 2017

sdilts commented Oct 12, 2017

@albertodonato

This comment has been minimized.

Show comment
Hide comment
@albertodonato

albertodonato Oct 12, 2017

@sdilts I'm not calling anything explicitly, this keeps popping up in messages when I edit python files, even if I just open an empty one.

albertodonato commented Oct 12, 2017

@sdilts I'm not calling anything explicitly, this keeps popping up in messages when I edit python files, even if I just open an empty one.

@albertodonato

This comment has been minimized.

Show comment
Hide comment
@albertodonato

albertodonato Oct 12, 2017

This is a trace of the server running with debug:

$ ~/virtualenv/emacs/bin/jediepcserver --port-file ~/.emacs-packages/jedi-core-20170121.610/jedi-port.log --ipdb
(AutoLog) Called: EPCHandler.setup()
(AutoLog) Returns: EPCHandler.setup(...) = None
(AutoLog) Called: EPCHandler.handle()
receiving...
received: length = 94; data = b'(call 203 defined_names ("\nimport argparse\n\nargparse\n\n\nargparse.\n" "/home/ack/Desktop/t.py"))\n'
(AutoLog) Called: EPCHandler._handle(b'(call 203 defined_names ("\nimport argparse\n\nargparse\n\n\nargparse.\n" "/home/ack/Desktop/t.py"))\n')
(AutoLog) Called: EPCHandler._handle_call(203, Symbol('defined_names'), ['\nimport argparse\n\nargparse\n\n\nargparse.\n', '/home/ack/Desktop/t.py'])
ERROR:epc:AttributeError("module 'jedi.api' has no attribute 'defined_names'",)
AttributeError("module 'jedi.api' has no attribute 'defined_names'",)
ERROR:epc:Unexpected error
Traceback (most recent call last):
  File "/home/ack/virtualenv/emacs/lib/python3.6/site-packages/epc/handler.py", line 242, in _handle
    reply = handler(uid, *args)
  File "/home/ack/virtualenv/emacs/lib/python3.6/site-packages/epc/utils.py", line 51, in new_method
    ret = method(self, *args, **kwds)
  File "/home/ack/virtualenv/emacs/lib/python3.6/site-packages/epc/handler.py", line 265, in _handle_call
    return ['return', uid, func(*args)]
  File "/home/ack/virtualenv/emacs/lib/python3.6/site-packages/jediepcserver.py", line 179, in defined_names
    return list(map(get_names_recursively, jedi.api.defined_names(*args)))
AttributeError: module 'jedi.api' has no attribute 'defined_names'
Unexpected error
Traceback (most recent call last):
  File "/home/ack/virtualenv/emacs/lib/python3.6/site-packages/epc/handler.py", line 242, in _handle
    reply = handler(uid, *args)
  File "/home/ack/virtualenv/emacs/lib/python3.6/site-packages/epc/utils.py", line 51, in new_method
    ret = method(self, *args, **kwds)
  File "/home/ack/virtualenv/emacs/lib/python3.6/site-packages/epc/handler.py", line 265, in _handle_call
    return ['return', uid, func(*args)]
  File "/home/ack/virtualenv/emacs/lib/python3.6/site-packages/jediepcserver.py", line 179, in defined_names
    return list(map(get_names_recursively, jedi.api.defined_names(*args)))
AttributeError: module 'jedi.api' has no attribute 'defined_names'

albertodonato commented Oct 12, 2017

This is a trace of the server running with debug:

$ ~/virtualenv/emacs/bin/jediepcserver --port-file ~/.emacs-packages/jedi-core-20170121.610/jedi-port.log --ipdb
(AutoLog) Called: EPCHandler.setup()
(AutoLog) Returns: EPCHandler.setup(...) = None
(AutoLog) Called: EPCHandler.handle()
receiving...
received: length = 94; data = b'(call 203 defined_names ("\nimport argparse\n\nargparse\n\n\nargparse.\n" "/home/ack/Desktop/t.py"))\n'
(AutoLog) Called: EPCHandler._handle(b'(call 203 defined_names ("\nimport argparse\n\nargparse\n\n\nargparse.\n" "/home/ack/Desktop/t.py"))\n')
(AutoLog) Called: EPCHandler._handle_call(203, Symbol('defined_names'), ['\nimport argparse\n\nargparse\n\n\nargparse.\n', '/home/ack/Desktop/t.py'])
ERROR:epc:AttributeError("module 'jedi.api' has no attribute 'defined_names'",)
AttributeError("module 'jedi.api' has no attribute 'defined_names'",)
ERROR:epc:Unexpected error
Traceback (most recent call last):
  File "/home/ack/virtualenv/emacs/lib/python3.6/site-packages/epc/handler.py", line 242, in _handle
    reply = handler(uid, *args)
  File "/home/ack/virtualenv/emacs/lib/python3.6/site-packages/epc/utils.py", line 51, in new_method
    ret = method(self, *args, **kwds)
  File "/home/ack/virtualenv/emacs/lib/python3.6/site-packages/epc/handler.py", line 265, in _handle_call
    return ['return', uid, func(*args)]
  File "/home/ack/virtualenv/emacs/lib/python3.6/site-packages/jediepcserver.py", line 179, in defined_names
    return list(map(get_names_recursively, jedi.api.defined_names(*args)))
AttributeError: module 'jedi.api' has no attribute 'defined_names'
Unexpected error
Traceback (most recent call last):
  File "/home/ack/virtualenv/emacs/lib/python3.6/site-packages/epc/handler.py", line 242, in _handle
    reply = handler(uid, *args)
  File "/home/ack/virtualenv/emacs/lib/python3.6/site-packages/epc/utils.py", line 51, in new_method
    ret = method(self, *args, **kwds)
  File "/home/ack/virtualenv/emacs/lib/python3.6/site-packages/epc/handler.py", line 265, in _handle_call
    return ['return', uid, func(*args)]
  File "/home/ack/virtualenv/emacs/lib/python3.6/site-packages/jediepcserver.py", line 179, in defined_names
    return list(map(get_names_recursively, jedi.api.defined_names(*args)))
AttributeError: module 'jedi.api' has no attribute 'defined_names'
@jrab89

This comment has been minimized.

Show comment
Hide comment
@jrab89

jrab89 Oct 23, 2017

My eldoc-style call signature help recently stopped working. If I run jedi:get-in-function-call I get:

deferred error : (error "\"AttributeError(\\\"'Definition' object has no attribute 'get_code'\\\",)\"")

jrab89 commented Oct 23, 2017

My eldoc-style call signature help recently stopped working. If I run jedi:get-in-function-call I get:

deferred error : (error "\"AttributeError(\\\"'Definition' object has no attribute 'get_code'\\\",)\"")

@albertodonato

This comment has been minimized.

Show comment
Hide comment
@albertodonato

albertodonato Oct 23, 2017

It seems defined_names is part of a depreated API that was dropped in jedi 0.11.0 (davidhalter/jedi@d6a04b2)

albertodonato commented Oct 23, 2017

It seems defined_names is part of a depreated API that was dropped in jedi 0.11.0 (davidhalter/jedi@d6a04b2)

@albertodonato albertodonato referenced a pull request that will close this issue Oct 23, 2017

Open

Replace defined_names() with names() #296

@jrab89

This comment has been minimized.

Show comment
Hide comment
@jrab89

jrab89 Oct 23, 2017

@albertodonato I uninstalled jedi 0.11.0 in my emacs' virtualenv and installed jedi 0.10.2 and now my eldoc-style call signature help is working again 😄

jrab89 commented Oct 23, 2017

@albertodonato I uninstalled jedi 0.11.0 in my emacs' virtualenv and installed jedi 0.10.2 and now my eldoc-style call signature help is working again 😄

@albertodonato

This comment has been minimized.

Show comment
Hide comment
@albertodonato

albertodonato Oct 23, 2017

@jrab89 the PR above fixes it for me with 0.11.0 too

albertodonato commented Oct 23, 2017

@jrab89 the PR above fixes it for me with 0.11.0 too

@sdilts

This comment has been minimized.

Show comment
Hide comment
@sdilts

sdilts Oct 23, 2017

There is a second place where it needs to be changed, which I added in this pull request: Fixed Issue #294

sdilts commented Oct 23, 2017

There is a second place where it needs to be changed, which I added in this pull request: Fixed Issue #294

@albertodonato

This comment has been minimized.

Show comment
Hide comment
@albertodonato

albertodonato Nov 14, 2017

@tkf could you consider #294 and #296 for merging to fix this issue?

albertodonato commented Nov 14, 2017

@tkf could you consider #294 and #296 for merging to fix this issue?

@Yevgnen

This comment has been minimized.

Show comment
Hide comment
@Yevgnen

Yevgnen Jan 31, 2018

Any update?

Yevgnen commented Jan 31, 2018

Any update?

@RobinTournemenne

This comment has been minimized.

Show comment
Hide comment
@RobinTournemenne

RobinTournemenne Jan 31, 2018

(This message is intended for newbies like me). I tried the solution of @albertodonato and @sdilts but my level in emacs and python was too low to make it work (I modified by hand line 103 105 and 179 of jediepcserver.py of the folder elpa/jedi-core/ + installing again everything).

The solution of @jrab89 was the winner: i installed in my real python (compared to the virtualenv one created by jedi.el) an older version of jedi: pip3 install jedi==0.10.2 (pip3 because I run python on mac OS which is a mess: https://docs.brew.sh/Homebrew-and-Python.html)

By the way, yes, jedi and jedi.el are two completely different "things".

Then an old-fashioned copy and replace of the two folders jedi/ jedi-0.10.2.dist-info/ located in the site-packages/ folder of my real python3 environment in the site-packages/ folder of the virtualenv created by jedi.el did the trick.

Good luck!

RobinTournemenne commented Jan 31, 2018

(This message is intended for newbies like me). I tried the solution of @albertodonato and @sdilts but my level in emacs and python was too low to make it work (I modified by hand line 103 105 and 179 of jediepcserver.py of the folder elpa/jedi-core/ + installing again everything).

The solution of @jrab89 was the winner: i installed in my real python (compared to the virtualenv one created by jedi.el) an older version of jedi: pip3 install jedi==0.10.2 (pip3 because I run python on mac OS which is a mess: https://docs.brew.sh/Homebrew-and-Python.html)

By the way, yes, jedi and jedi.el are two completely different "things".

Then an old-fashioned copy and replace of the two folders jedi/ jedi-0.10.2.dist-info/ located in the site-packages/ folder of my real python3 environment in the site-packages/ folder of the virtualenv created by jedi.el did the trick.

Good luck!

Yevgnen added a commit to Yevgnen/emacs-jedi that referenced this issue Apr 28, 2018

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment