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

jedi 0.18.0 incompatibilities - anaconda-eldoc-mode causes TypeError: __init__() takes from 1 to 2 positional arguments but 5 positional arguments (and 1 keyword-only argument) were given #401

Closed
Mekk opened this issue Dec 31, 2020 · 14 comments · Fixed by #403

Comments

@Mekk
Copy link

Mekk commented Dec 31, 2020

I am just trying doom emacs, and on python files I get repeatable TypeErrors while editing python files (full traceback below). After some analysis I found that disabling anaconda-eldoc-mode resolves the issue, so the problem lies there.

*anaconda-mode* buffer contains numerous entries like:

Traceback (most recent call last):
  File "/home/marcink/DEV_git/emacs/doom-emacs/.local/etc/anaconda/0.1.13/service_factory-0.1.6-py3.8.egg/service_factory/service.py", line 101, in apply
    result = method(**params)
  File "<string>", line 99, in wrapper
TypeError: __init__() takes from 1 to 2 positional arguments but 5 positional arguments (and 1 keyword-only argument) were given

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/home/marcink/DEV_git/emacs/doom-emacs/.local/etc/anaconda/0.1.13/service_factory-0.1.6-py3.8.egg/service_factory/providers/basehttp.py", line 40, in do_POST
    status, response = self.server.service(data)
  File "/home/marcink/DEV_git/emacs/doom-emacs/.local/etc/anaconda/0.1.13/service_factory-0.1.6-py3.8.egg/service_factory/service.py", line 50, in __call__
    result = self.apply(method, args)
  File "/home/marcink/DEV_git/emacs/doom-emacs/.local/etc/anaconda/0.1.13/service_factory-0.1.6-py3.8.egg/service_factory/service.py", line 105, in apply
    server_error(args['id'], error)
  File "/home/marcink/DEV_git/emacs/doom-emacs/.local/etc/anaconda/0.1.13/service_factory-0.1.6-py3.8.egg/service_factory/errors.py", line 91, in server_error
    raise ServiceException(500, dumps(response))
service_factory.exceptions.ServiceException: (500, '{"jsonrpc": "2.0", "id": 1, "error": {"code": -32000, "message": "Server error", "data": "TypeError(\'__init__() takes from 1 to 2 positional arguments but 5 positional arguments (and 1 keyword-only argument) were given\')"}}')

(and again, and again, and again…)

@Mekk
Copy link
Author

Mekk commented Dec 31, 2020

I patched anaconda slightly to give more detail about what was called (simply by extending error message to note which called function crashed) and here it is:

service_factory.exceptions.ServiceException: (500, '{"jsonrpc": "2.0", "id": 1, "error": {"code": -32000, "message": "Server error: Calling <function eldoc at 0x7f7c79d31160> with named args: source=..., line=17, column=11, path=\'/home/marcink/GAUSS/python/sfx__repository/sample/repo/basic_log.py\'", "data": "TypeError(\'__init__() takes from 1 to 2 positional arguments but 5 positional arguments (and 1 keyword-only argument) were given\')"}}')

@Mekk
Copy link
Author

Mekk commented Dec 31, 2020

I am not 100% sure, but it seems to me that aforementioned line 99 is related to python code snippet defined inside anaconda-mode-server-command. If so, it is triggered by:

result = f(jedi.Script(source, line, column, path, environment=virtual_environment))

what also matches error message

@Mekk
Copy link
Author

Mekk commented Dec 31, 2020

Doom emacs uses anaconda 0.1.13 and jedi 0.18.0. Jedi sources have the following there:

def __init__(self, code=None, *, path=None, environment=None, project=None):

so looks like giving positional args is not supported here.

@Mekk
Copy link
Author

Mekk commented Dec 31, 2020

I resolved this by changing to

result = f(jedi.Script(source, path=path, environment=virtual_environment))

but then next error appears:

Traceback (most recent call last):
  File "/home/marcink/DEV_git/emacs/doom-emacs/.local/etc/anaconda/0.1.13/service_factory-0.1.6-py3.8.egg/service_factory/service.py", line 101, in apply
    result = method(**params)
  File "<string>", line 100, in wrapper
  File "<string>", line 156, in eldoc
AttributeError: 'Script' object has no attribute 'call_signatures'

so looks like there is some deeper incompatibility.

0.18.0 seems to be the newest and brightest version of jedi, so I bet it changed in incompatible way at some moment.

@Mekk
Copy link
Author

Mekk commented Dec 31, 2020

Jedi changelog mentions deprecating call_signatures in entry for 0.16.0.
Looking at the repo, it seems the method was actually removed at 0.18.0 (0.17.2 has it).

So I suppose this bug is about patching anaconda to work with jedi 0.18.0.

@Mekk Mekk changed the title (from anaconda-eldoc-mode) TypeError: __init__() takes from 1 to 2 positional arguments but 5 positional arguments (and 1 keyword-only argument) were given jedi 0.18.0 incompatibilities - anaconda-eldoc-mode causes TypeError: __init__() takes from 1 to 2 positional arguments but 5 positional arguments (and 1 keyword-only argument) were given Dec 31, 2020
@Mekk
Copy link
Author

Mekk commented Dec 31, 2020

As a side note, it seems anaconda-mode.el doesn't restrict jedi version installed: it constructs pip dependency jedi>=0.13.0 but doesn't limit upper version. Probably it would be better to limit two-side.

@Mekk
Copy link
Author

Mekk commented Dec 31, 2020

I reported the latter problem separately, as #402. This issue is about making anaconda work with jedi 0.18.0

@dakra
Copy link
Member

dakra commented Dec 31, 2020

By default anaconda installs a rather old version 0.13.

0.18 is only 6 days old though and not a good choice for anaconda as
it doesn't have python 2 support.

But I agree that anaconda should also work with 0.18 if that's installed.
Would be great if you can help with a PR that supports both (all) jedi versions.

@Mekk
Copy link
Author

Mekk commented Dec 31, 2020

Unfortunately anaconda doesn't install jedi 0.13 by default. It installs newest version available on pypi at the moment (it asks for jedi>=0.13 what since Dec 25th results in 0.18). But that's #402.

PS Force-downgrading jedi to 0.17.2 seems to help (alth. I tested it very briefly). So I'd suggest starting from #402 and adding <0.18 restriction for jedi there, to resolve the immediate issue.

dakra added a commit to dakra/anaconda-mode that referenced this issue Jan 1, 2021
Fix compatibility issues with jedi version 0.18.
Require specific version of jedi and service_factory.
Fall back to jedi 0.17.2 on python 2.

See https://jedi.readthedocs.io/en/latest/docs/changelog.html

Fix pythonic-emacs#401
Related pythonic-emacs#402
@dakra
Copy link
Member

dakra commented Jan 1, 2021

@Mekk Can you check if #403 works ?

@Mekk
Copy link
Author

Mekk commented Jan 1, 2021

I tested it briefly and seems it is OK (jedi 0.18 was installed but now I don't see errors and eldoc hints are displayed).

@1buran
Copy link

1buran commented Jan 3, 2021

@Mekk Can you check if #403 works ?

Works fine for me too, thanks!

Recently I upgraded python to 3.9 on my laptop and rebuild all environments, anaconda-mode was broken due to installed fresh version of jedi.

Thanks @dakra for his patch, it solved the problem!

@Mekk
Copy link
Author

Mekk commented Jan 7, 2021

For the sake of possible Doom! Emacs users, adding to packages.el:

(package! anaconda-mode
  :recipe (:host github :repo "dakra/anaconda-mode")
  :pin "810163d5a65e62d58f363e2edaa3be70e6d82e25")

switches to this patched version.

@dakra dakra closed this as completed in 80afec2 Jan 8, 2021
@dakra
Copy link
Member

dakra commented Jan 8, 2021

I merged the PR and also created a new version tag so users of melpa-stable will get it too.

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

Successfully merging a pull request may close this issue.

3 participants