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

Python language server breaks autocomplete on Python 3.11 #959

Open
ptr33 opened this issue Dec 16, 2022 · 4 comments
Open

Python language server breaks autocomplete on Python 3.11 #959

ptr33 opened this issue Dec 16, 2022 · 4 comments

Comments

@ptr33
Copy link

ptr33 commented Dec 16, 2022

Hi,

I installed python language server which requires jedi==0.17.3 which breaks my autocomplete in Python 3.11 in a Jupyterlab notebook. Pressing <tab> in a notebook generates following errro:

Traceback (most recent call last):
  File "/usr/local/lib/python3.11/site-packages/jedi/cache.py", line 109, in wrapper
    return dct[key]
           ~~~^^^^^
KeyError: ((), frozenset())

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/local/lib/python3.11/site-packages/parso/grammar.py", line 246, in load_grammar
    return _loaded_grammars[path]
           ~~~~~~~~~~~~~~~~^^^^^^
KeyError: '/usr/local/lib/python3.11/site-packages/parso/python/grammar311.txt'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/local/lib/python3.11/site-packages/parso/grammar.py", line 249, in load_grammar
    with open(path) as f:
         ^^^^^^^^^^
FileNotFoundError: [Errno 2] No such file or directory: '/usr/local/lib/python3.11/site-packages/parso/python/grammar311.txt'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/local/lib/python3.11/site-packages/pyls_jsonrpc/endpoint.py", line 113, in consume
    self._handle_request(message['id'], message['method'], message.get('params'))
  File "/usr/local/lib/python3.11/site-packages/pyls_jsonrpc/endpoint.py", line 182, in _handle_request
    handler_result = handler(params)
                     ^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/pyls_jsonrpc/dispatchers.py", line 23, in handler
    return method(**(params or {}))
           ^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/pyls/python_ls.py", line 328, in m_text_document__document_highlight
  File "/usr/local/lib/python3.11/site-packages/pyls/python_ls.py", line 262, in highlight
  File "/usr/local/lib/python3.11/site-packages/pyls/python_ls.py", line 156, in _hook
  File "/usr/local/lib/python3.11/site-packages/pluggy/_hooks.py", line 265, in __call__
    return self._hookexec(self.name, self.get_hookimpls(), kwargs, firstresult)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/pluggy/_manager.py", line 80, in _hookexec
    return self._inner_hookexec(hook_name, methods, kwargs, firstresult)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/pluggy/_manager.py", line 327, in traced_hookexec
    return outcome.get_result()
           ^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/pluggy/_result.py", line 60, in get_result
    raise ex[1].with_traceback(ex[2])
  File "/usr/local/lib/python3.11/site-packages/pluggy/_result.py", line 33, in from_call
    result = func()
             ^^^^^^
  File "/usr/local/lib/python3.11/site-packages/pluggy/_manager.py", line 324, in <lambda>
    lambda: oldcall(hook_name, hook_impls, kwargs, firstresult)
            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/pluggy/_callers.py", line 60, in _multicall
    return outcome.get_result()
           ^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/pluggy/_result.py", line 60, in get_result
    raise ex[1].with_traceback(ex[2])
  File "/usr/local/lib/python3.11/site-packages/pluggy/_callers.py", line 39, in _multicall
    res = hook_impl.function(*args)
          ^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/pyls/plugins/highlight.py", line 11, in pyls_document_highlight
  File "/usr/local/lib/python3.11/site-packages/pyls/workspace.py", line 25, in wrapper
  File "/usr/local/lib/python3.11/site-packages/pyls/workspace.py", line 279, in jedi_script
  File "/usr/local/lib/python3.11/site-packages/jedi/api/__init__.py", line 184, in __init__
    self._inference_state = InferenceState(
                            ^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/jedi/inference/__init__.py", line 91, in __init__
    self.grammar = environment.get_grammar()
                   ^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/jedi/cache.py", line 111, in wrapper
    result = method(self, *args, **kwargs)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/jedi/api/environment.py", line 37, in get_grammar
    return parso.load_grammar(version=version_string)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/parso/grammar.py", line 260, in load_grammar
    return load_grammar(**kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/parso/grammar.py", line 256, in load_grammar
    raise NotImplementedError(message)
NotImplementedError: Python version 3.11 is currently not supported.

I used following docker container:

docker run --rm -it -p 8888:8888 ghcr.io/ptr33/jupyterlab:3.11

and open http://localhost:8888/jupyter

In this docker container after running

pip uninstall python-language-server 
pip install jedi==0.18.2 

autocomplete works again.

Any idea to use the language server with Python 3.11?

Thank you
ptr33

@ptr33 ptr33 changed the title Python language server breaks autocomplete on Python 3.11 in docker Python language server breaks autocomplete on Python 3.11 Dec 19, 2022
@Shabbyshambles
Copy link

There is no 0.17.3 release of Jedi, at least not recorded in the changelog, but if you are using 0.17.2 then it came out over 2 years before 3.11, that release of Jedi won't support Python versions beyond 3.9. Version support for Python version 3.11 is not listed in the most recent update of Jedi, but it came out more recently than version 3.11 so your best bet is either resetting to Python 3.9 for use with Jedi 0.17.2, or using 0.18.2 with Python 3.11. I doubt that has 3.11 support though tbh

@ptr33
Copy link
Author

ptr33 commented Jan 26, 2023

Hi @Shabbyshambles,
thank you for your comment - currently python-language-server does not work together with the latest jedi release (0.18.2 from 21 Nov 2022 https://pypi.org/project/jedi/0.18.2/#history) - is it possible to make a new release of the python-language-server which uses this version?

Thanks
ptr33

@wenijinew
Copy link

Yes, waiting for the support of Python version 3.11. Thanks!
LSP :: Error from the Language Server: NotImplementedError: Python version 3.11 is currently not supported. (Invalid Parameters)

@benjamin-kirkbride
Copy link

#969

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

4 participants