pythonic-emacs / anaconda-mode

Code navigation, documentation lookup and completion for Python.
GNU General Public License v3.0
706 stars 87 forks source link

A server errors appears as I interact with the server #425

Closed manueldeljesus closed 1 year ago

manueldeljesus commented 1 year ago

I am using Emacs 28.1 on Fedora 36 with Doom Emacs distribution. I am trying to use anaconda-mode in a very simple python file (importing numpy and trying to use linspace). As I am halfway writing the function name I try to autocomplete and the following error appears:

anaconda_mode port 37753
127.0.0.1 - - [19/Nov/2022 14:04:53] ================================================================================
Traceback (most recent call last):
  File "/home/manuel/.emacs.d/.local/etc/anaconda/0.1.15-py3/service_factory/service.py", line 101, in apply
    result = method(**params)
  File "/home/manuel/.emacs.d/.local/straight/build-28.1/anaconda-mode/anaconda-mode.py", line 138, in wrapper
    result = f(jedi.Script(source, path=path, environment=virtual_environment), line, column)
  File "/home/manuel/.emacs.d/.local/straight/build-28.1/anaconda-mode/anaconda-mode.py", line 161, in complete
    for definition in script.complete(line, column)]
  File "/home/manuel/.emacs.d/.local/etc/anaconda/0.1.15-py3/jedi/api/helpers.py", line 487, in wrapper
    return func(self, line, column, *args, **kwargs)
  File "/home/manuel/.emacs.d/.local/etc/anaconda/0.1.15-py3/jedi/api/__init__.py", line 214, in complete
    return completion.complete()
  File "/home/manuel/.emacs.d/.local/etc/anaconda/0.1.15-py3/jedi/api/completion.py", line 170, in complete
    cached_name, completion_names = self._complete_python(leaf)
  File "/home/manuel/.emacs.d/.local/etc/anaconda/0.1.15-py3/jedi/api/completion.py", line 284, in _complete_python
    cached_name, n = self._complete_trailer(dot.get_previous_leaf())
  File "/home/manuel/.emacs.d/.local/etc/anaconda/0.1.15-py3/jedi/api/completion.py", line 399, in _complete_trailer
    return cached_name, self._complete_trailer_for_values(values)
  File "/home/manuel/.emacs.d/.local/etc/anaconda/0.1.15-py3/jedi/api/completion.py", line 404, in _complete_trailer_for_values
    return complete_trailer(user_context, values)
  File "/home/manuel/.emacs.d/.local/etc/anaconda/0.1.15-py3/jedi/api/completion.py", line 550, in complete_trailer
    completion_names += filter.values()
  File "/home/manuel/.emacs.d/.local/etc/anaconda/0.1.15-py3/jedi/inference/filters.py", line 117, in values
    return self._convert_names(
  File "/home/manuel/.emacs.d/.local/etc/anaconda/0.1.15-py3/jedi/inference/filters.py", line 114, in _convert_names
    return [self.name_class(self.parent_context, name) for name in names]
  File "/home/manuel/.emacs.d/.local/etc/anaconda/0.1.15-py3/jedi/inference/filters.py", line 114, in <listcomp>
    return [self.name_class(self.parent_context, name) for name in names]
  File "/home/manuel/.emacs.d/.local/etc/anaconda/0.1.15-py3/jedi/inference/filters.py", line 120, in <genexpr>
    for name in self._filter(
  File "/home/manuel/.emacs.d/.local/etc/anaconda/0.1.15-py3/jedi/inference/filters.py", line 144, in _filter
    names = [n for n in names if self._is_name_reachable(n)]
  File "/home/manuel/.emacs.d/.local/etc/anaconda/0.1.15-py3/jedi/inference/filters.py", line 144, in <listcomp>
    names = [n for n in names if self._is_name_reachable(n)]
  File "/home/manuel/.emacs.d/.local/etc/anaconda/0.1.15-py3/jedi/inference/gradual/stub_value.py", line 89, in _is_name_reachable
    if definition.type in ('import_from', 'import_name'):
AttributeError: 'NoneType' object has no attribute 'type'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/home/manuel/.emacs.d/.local/etc/anaconda/0.1.15-py3/service_factory/providers/basehttp.py", line 40, in do_POST
    status, response = self.server.service(data)
  File "/home/manuel/.emacs.d/.local/etc/anaconda/0.1.15-py3/service_factory/service.py", line 50, in __call__
    result = self.apply(method, args)
  File "/home/manuel/.emacs.d/.local/etc/anaconda/0.1.15-py3/service_factory/service.py", line 105, in apply
    server_error(args['id'], error)
  File "/home/manuel/.emacs.d/.local/etc/anaconda/0.1.15-py3/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": "AttributeError(\\"\'NoneType\' object has no attribute \'type\'\\")"}}')

Any idea on how to debug the problem further or how to solve it?

Any help will be much appreciated

dakra commented 1 year ago

This is a bug with jedi and the latest numpy. See https://github.com/davidhalter/jedi/issues/1864

Should automatically be fixed once there is a new jedi version. If you want to patch it manually earlier, I guess you can go to anaconda-mode-installation-directory and update/patch the jedi version installed in this virtualenv.

manueldeljesus commented 1 year ago

Thank you very much for the answer.

I was testing anaconda-mode and starting with numpy. I assumed that it was not going to work for any other python library, but didn't test it.

I'll wait for jedi to update.