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

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

Closed
sdilts opened this issue Sep 28, 2017 · 13 comments

Comments

@sdilts
Copy link

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 deferred error : (error "\"AttributeError(\\\"'Definition' object has no attribute 'get_code'\\\",)\"") deferred error : (error ""AttributeError("'Definition' object has no attribute 'get_code' ",)"") Sep 28, 2017
@albertodonato
Copy link

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
Copy link
Author

sdilts commented Oct 12, 2017 via email

@albertodonato
Copy link

@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
Copy link

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
Copy link

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
Copy link

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

@jrab89
Copy link

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
Copy link

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

@sdilts
Copy link
Author

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
Copy link

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

@Yevgnen
Copy link

Yevgnen commented Jan 31, 2018

Any update?

@RobinTournemenne
Copy link

(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!

@immerrr
Copy link
Collaborator

immerrr commented Nov 3, 2018

Hi , I've taken over maintainership of emacs-jedi and hopefully now we will be able to catch up with the recent jedi developments. I believe I have fixed this issue with #315. Please, try out the current master branch and let me know if it persists.

@immerrr immerrr closed this as completed Nov 3, 2018
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

6 participants