lite-xl / lite-xl-lsp

LSP Plugin for Lite XL editor
MIT License
159 stars 21 forks source link

[Bug] Wrong line number gets sent to the LSP server, resulting in errors #80

Closed ghost closed 7 months ago

ghost commented 12 months ago

Aaand I'm back again, this time with some more errors:

Tue Nov  7 23:14:51 2023 [INFO] [LSP/Jedi]: Processing Response:
{"id":3,"error":{"code":-32603,"message":"EOFError: Ran out of input","data":"{'traceback': ['  File \"/home/user/.local/lib/python3.11/site-packages/pygls/protocol/json_rpc.py\", line 265, in _handle_request\\n    self._execute_request(msg_id, handler, params)\\n', '  File \"/home/user/.local/lib/python3.11/site-packages/pygls/protocol/json_rpc.py\", line 187, in _execute_request\\n    self._send_response(msg_id, handler(params))\\n                                ^^^^^^^^^^^^^^^\\n', '  File \"/home/user/.local/lib/python3.11/site-packages/jedi_language_server/server.py\", line 383, in hover\\n    hover_text = jedi_utils.hover_text(\\n                 ^^^^^^^^^^^^^^^^^^^^^^\\n', '  File \"/home/user/.local/lib/python3.11/site-packages/jedi_language_server/jedi_utils.py\", line 665, in hover_text\\n    header_plain = \"\\\\n\".join(get_full_signatures(name))\\n                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\\n', '  File \"/home/user/.local/lib/python3.11/site-packages/jedi_language_server/jedi_utils.py\", line 609, in get_full_signatures\\n    signatures = name.get_signatures()\\n                 ^^^^^^^^^^^^^^^^^^^^^\\n', '  File \"/home/user/.local/lib/python3.11/site-packages/jedi/api/classes.py\", line 581, in get_signatures\\n    for s in self._get_signatures()\\n             ^^^^^^^^^^^^^^^^^^^^^^\\n', '  File \"/home/user/.local/lib/python3.11/site-packages/jedi/api/classes.py\", line 570, in _get_signatures\\n    return [sig for name in names for sig in name.infer().get_signatures()]\\n           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\\n', '  File \"/home/user/.local/lib/python3.11/site-packages/jedi/api/classes.py\", line 570, in <listcomp>\\n    return [sig for name in names for sig in name.infer().get_signatures()]\\n                                             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\\n', '  File \"/home/user/.local/lib/python3.11/site-packages/jedi/inference/base_value.py\", line 516, in get_signatures\\n    return [sig for c in self._set for sig in c.get_signatures()]\\n           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\\n', '  File \"/home/user/.local/lib/python3.11/site-packages/jedi/inference/base_value.py\", line 516, in <listcomp>\\n    return [sig for c in self._set for sig in c.get_signatures()]\\n                                              ^^^^^^^^^^^^^^^^^^\\n', '  File \"/home/user/.local/lib/python3.11/site-packages/jedi/inference/value/klass.py\", line 228, in get_signatures\\n    metaclasses = self.get_metaclasses()\\n                  ^^^^^^^^^^^^^^^^^^^^^^\\n', '  File \"/home/user/.local/lib/python3.11/site-packages/jedi/inference/cache.py\", line 44, in wrapper\\n    rv = function(obj, *args, **kwargs)\\n         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\\n', '  File \"/home/user/.local/lib/python3.11/site-packages/jedi/inference/value/klass.py\", line 380, in get_metaclasses\\n    for lazy_base in self.py__bases__():\\n                     ^^^^^^^^^^^^^^^^^^\\n', '  File \"/home/user/.local/lib/python3.11/site-packages/jedi/inference/cache.py\", line 44, in wrapper\\n    rv = function(obj, *args, **kwargs)\\n         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\\n', '  File \"/home/user/.local/lib/python3.11/site-packages/jedi/inference/value/klass.py\", line 362, in py__bases__\\n    self.inference_state.builtins_module.py__getattribute__(\\'object\\')\\n    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\\n', '  File \"/home/user/.local/lib/python3.11/site-packages/jedi/inference/cache.py\", line 44, in wrapper\\n    rv = function(obj, *args, **kwargs)\\n         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\\n', '  File \"/home/user/.local/lib/python3.11/site-packages/jedi/inference/__init__.py\", line 129, in builtins_module\\n    builtins_module, = self.import_module((module_name,), sys_path=[])\\n                       ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\\n', '  File \"/home/user/.local/lib/python3.11/site-packages/jedi/inference/__init__.py\", line 112, in import_module\\n    return imports.import_module_by_names(\\n           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\\n', '  File \"/home/user/.local/lib/python3.11/site-packages/jedi/inference/imports.py\", line 376, in import_module_by_names\\n    value_set = ValueSet.from_sets([\\n                                   ^\\n', '  File \"/home/user/.local/lib/python3.11/site-packages/jedi/inference/imports.py\", line 377, in <listcomp>\\n    import_module(\\n', '  File \"/home/user/.local/lib/python3.11/site-packages/jedi/plugins/__init__.py\", line 21, in wrapper\\n    return built_functions[public_name](*args, **kwargs)\\n           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\\n', '  File \"/home/user/.local/lib/python3.11/site-packages/jedi/plugins/flask.py\", line 20, in wrapper\\n    return callback(inference_state, import_names, module_context, *args, **kwargs)\\n           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\\n', '  File \"/home/user/.local/lib/python3.11/site-packages/jedi/inference/gradual/typeshed.py\", line 124, in wrapper\\n    stub = try_to_load_stub_cached(inference_state, import_names, python_value_set,\\n           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\\n', '  File \"/home/user/.local/lib/python3.11/site-packages/jedi/inference/gradual/typeshed.py\", line 146, in try_to_load_stub_cached\\n    _try_to_load_stub(inference_state, import_names, *args, **kwargs)\\n', '  File \"/home/user/.local/lib/python3.11/site-packages/jedi/inference/gradual/typeshed.py\", line 213, in _try_to_load_stub\\n    m = _load_from_typeshed(inference_state, python_value_set, parent_module_value, import_names)\\n        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\\n', '  File \"/home/user/.local/lib/python3.11/site-packages/jedi/inference/gradual/typeshed.py\", line 263, in _load_from_typeshed\\n    return _try_to_load_stub_from_file(\\n           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^\\n', '  File \"/home/user/.local/lib/python3.11/site-packages/jedi/inference/gradual/typeshed.py\", line 273, in _try_to_load_stub_from_file\\n    stub_module_node = parse_stub_module(inference_state, file_io)\\n                       ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\\n', '  File \"/home/user/.local/lib/python3.11/site-packages/jedi/inference/gradual/typeshed.py\", line 285, in parse_stub_module\\n    return inference_state.parse(\\n           ^^^^^^^^^^^^^^^^^^^^^^\\n', '  File \"/home/user/.local/lib/python3.11/site-packages/jedi/inference/__init__.py\", line 199, in parse\\n    return self.parse_and_get_code(*args, **kwargs)[0]\\n           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\\n', '  File \"/home/user/.local/lib/python3.11/site-packages/jedi/inference/__init__.py\", line 196, in parse_and_get_code\\n    return grammar.parse(code=code, path=path, file_io=file_io, **kwargs), code\\n           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\\n', '  File \"/home/user/.local/lib/python3.11/site-packages/parso/grammar.py\", line 114, in parse\\n    module_node = load_module(self._hashed, file_io, cache_path=cache_path)\\n                  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\\n', '  File \"/home/user/.local/lib/python3.11/site-packages/parso/cache.py\", line 127, in load_module\\n    return _load_from_file_system(\\n           ^^^^^^^^^^^^^^^^^^^^^^^\\n', '  File \"/home/user/.local/lib/python3.11/site-packages/parso/cache.py\", line 145, in _load_from_file_system\\n    module_cache_item = pickle.load(f)\\n                        ^^^^^^^^^^^^^^\\n']}"},"jsonrpc":"2.0"}
 at /home/user/.config/lite-xl/plugins/lsp/init.lua:780
Tue Nov  7 23:14:51 2023 [INFO] [LSP/Jedi]: Response header and content received at once:
Content-Length: 7642
Content-Type: application/vscode-jsonrpc; charset=utf-8

{"error": {"code": -32603, "message": "EOFError: Ran out of input", "data": "{'traceback': ['  File \"/home/user/.local/lib/python3.11/site-packages/pygls/protocol/json_rpc.py\", line 265, in _handle_request\\n    self._execute_request(msg_id, handler, params)\\n', '  File \"/home/user/.local/lib/python3.11/site-packages/pygls/protocol/json_rpc.py\", line 187, in _execute_request\\n    self._send_response(msg_id, handler(params))\\n                                ^^^^^^^^^^^^^^^\\n', '  File \"/home/user/.local/lib/python3.11/site-packages/jedi_language_server/server.py\", line 383, in hover\\n    hover_text = jedi_utils.hover_text(\\n                 ^^^^^^^^^^^^^^^^^^^^^^\\n', '  File \"/home/user/.local/lib/python3.11/site-packages/jedi_language_server/jedi_utils.py\", line 665, in hover_text\\n    header_plain = \"\\\\n\".join(get_full_signatures(name))\\n                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\\n', '  File \"/home/user/.local/lib/python3.11/site-packages/jedi_language_server/jedi_utils.py\", line 609, in get_full_signatures\\n    signatures = name.get_signatures()\\n                 ^^^^^^^^^^^^^^^^^^^^^\\n', '  File \"/home/user/.local/lib/python3.11/site-packages/jedi/api/classes.py\", line 581, in get_signatures\\n    for s in self._get_signatures()\\n             ^^^^^^^^^^^^^^^^^^^^^^\\n', '  File \"/home/user/.local/lib/python3.11/site-packages/jedi/api/classes.py\", line 570, in _get_signatures\\n    return [sig for name in names for sig in name.infer().get_signatures()]\\n           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\\n', '  File \"/home/user/.local/lib/python3.11/site-packages/jedi/api/classes.py\", line 570, in <listcomp>\\n    return [sig for name in names for sig in name.infer().get_signatures()]\\n                                             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\\n', '  File \"/home/user/.local/lib/python3.11/site-packages/jedi/inference/base_value.py\", line 516, in get_signatures\\n    return [sig for c in self._set for sig in c.get_signatures()]\\n           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\\n', '  File \"/home/user/.local/lib/python3.11/site-packages/jedi/inference/base_value.py\", line 516, in <listcomp>\\n    return [sig for c in self._set for sig in c.get_signatures()]\\n                                              ^^^^^^^^^^^^^^^^^^\\n', '  File \"/home/user/.local/lib/python3.11/site-packages/jedi/inference/value/klass.py\", line 228, in get_signatures\\n    metaclasses = self.get_metaclasses()\\n                  ^^^^^^^^^^^^^^^^^^^^^^\\n', '  File \"/home/user/.local/lib/python3.11/site-packages/jedi/inference/cache.py\", line 44, in wrapper\\n    rv = function(obj, *args, **kwargs)\\n         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\\n', '  File \"/home/user/.local/lib/python3.11/site-packages/jedi/inference/value/klass.py\", line 380, in get_metaclasses\\n    for lazy_base in self.py__bases__():\\n                     ^^^^^^^^^^^^^^^^^^\\n', '  File \"/home/user/.local/lib/python3.11/site-packages/jedi/inference/cache.py\", line 44, in wrapper\\n    rv = function(obj, *args, **kwargs)\\n         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\\n', '  File \"/home/user/.local/lib/python3.11/site-packages/jedi/inference/value/klass.py\", line 362, in py__bases__\\n    self.inference_state.builtins_module.py__getattribute__(\\'object\\')\\n    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\\n', '  File \"/home/user/.local/lib/python3.11/site-packages/jedi/inference/cache.py\", line 44, in wrapper\\n    rv = function(obj, *args, **kwargs)\\n         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\\n', '  File \"/home/user/.local/lib/python3.11/site-packages/jedi/inference/__init__.py\", line 129, in builtins_module\\n    builtins_module, = self.import_module((module_name,), sys_path=[])\\n                       ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\\n', '  File \"/home/user/.local/lib/python3.11/site-packages/jedi/inference/__init__.py\", line 112, in import_module\\n    return imports.import_module_by_names(\\n           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\\n', '  File \"/home/user/.local/lib/python3.11/site-packages/jedi/inference/imports.py\", line 376, in import_module_by_names\\n    value_set = ValueSet.from_sets([\\n                                   ^\\n', '  File \"/home/user/.local/lib/python3.11/site-packages/jedi/inference/imports.py\", line 377, in <listcomp>\\n    import_module(\\n', '  File \"/home/user/.local/lib/python3.11/site-packages/jedi/plugins/__init__.py\", line 21, in wrapper\\n    return built_functions[public_name](*args, **kwargs)\\n           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\\n', '  File \"/home/user/.local/lib/python3.11/site-packages/jedi/plugins/flask.py\", line 20, in wrapper\\n    return callback(inference_state, import_names, module_context, *args, **kwargs)\\n           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\\n', '  File \"/home/user/.local/lib/python3.11/site-packages/jedi/inference/gradual/typeshed.py\", line 124, in wrapper\\n    stub = try_to_load_stub_cached(inference_state, import_names, python_value_set,\\n           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\\n', '  File \"/home/user/.local/lib/python3.11/site-packages/jedi/inference/gradual/typeshed.py\", line 146, in try_to_load_stub_cached\\n    _try_to_load_stub(inference_state, import_names, *args, **kwargs)\\n', '  File \"/home/user/.local/lib/python3.11/site-packages/jedi/inference/gradual/typeshed.py\", line 213, in _try_to_load_stub\\n    m = _load_from_typeshed(inference_state, python_value_set, parent_module_value, import_names)\\n        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\\n', '  File \"/home/user/.local/lib/python3.11/site-packages/jedi/inference/gradual/typeshed.py\", line 263, in _load_from_typeshed\\n    return _try_to_load_stub_from_file(\\n           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^\\n', '  File \"/home/user/.local/lib/python3.11/site-packages/jedi/inference/gradual/typeshed.py\", line 273, in _try_to_load_stub_from_file\\n    stub_module_node = parse_stub_module(inference_state, file_io)\\n                       ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\\n', '  File \"/home/user/.local/lib/python3.11/site-packages/jedi/inference/gradual/typeshed.py\", line 285, in parse_stub_module\\n    return inference_state.parse(\\n           ^^^^^^^^^^^^^^^^^^^^^^\\n', '  File \"/home/user/.local/lib/python3.11/site-packages/jedi/inference/__init__.py\", line 199, in parse\\n    return self.parse_and_get_code(*args, **kwargs)[0]\\n           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\\n', '  File \"/home/user/.local/lib/python3.11/site-packages/jedi/inference/__init__.py\", line 196, in parse_and_get_code\\n    return grammar.parse(code=code, path=path, file_io=file_io, **kwargs), code\\n           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\\n', '  File \"/home/user/.local/lib/python3.11/site-packages/parso/grammar.py\", line 114, in parse\\n    module_node = load_module(self._hashed, file_io, cache_path=cache_path)\\n                  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\\n', '  File \"/home/user/.local/lib/python3.11/site-packages/parso/cache.py\", line 127, in load_module\\n    return _load_from_file_system(\\n           ^^^^^^^^^^^^^^^^^^^^^^^\\n', '  File \"/home/user/.local/lib/python3.11/site-packages/parso/cache.py\", line 145, in _load_from_file_system\\n    module_cache_item = pickle.load(f)\\n                        ^^^^^^^^^^^^^^\\n']}"}, "jsonrpc": "2.0", "id": 3}
 at /home/user/.config/lite-xl/plugins/lsp/init.lua:780
Tue Nov  7 23:14:51 2023 [INFO] [LSP/Jedi]: Sent request 'textDocument/hover':
{"params":{"position":{"character":8,"line":8},"textDocument":{"uri":"file:///home/user/Documents/Code/test.py"}},"id":3,"method":"textDocument/hover","jsonrpc":"2.0"}
 at /home/user/.config/lite-xl/plugins/lsp/init.lua:780
Tue Nov  7 23:14:51 2023 [INFO] [LSP/Jedi]: Adding request textDocument/hover
 at /home/user/.config/lite-xl/plugins/lsp/init.lua:780

It seems to me that for some reason the wrong line gets passed.

Code for reference:

class Foo():

    def __init__(self):
        self.name = "foo"

    def my_name(self):
        return self.name

foo = Foo()
print(foo.my_name())

When trying to highlight Foo(), the wrong line number gets sent to the LSP server:

Line 8 gets sent: 2023-11-07-231652_355x75_scrot

But Foo() is actually on Line 9 2023-11-07-231642_319x240_scrot

Guldoman commented 12 months ago

When trying to highlight Foo(), the wrong line number gets sent to the LSP server:

What do you mean by highlight? I guess like selecting with the mouse? Is this with LSP master, 0.5, or with PRs applied? Probably doesn't matter, but Lite XL master or 2.1.1?

Might be worth it to also know pylsp's version.

I'm testing your snippet with LSP master, Lite XL master and pylsp v1.8.0, and I'm getting the expected hover behavior:

Wed Nov  8 01:43:07 2023 [INFO] [LSP/pylsp]: Adding request textDocument/hover
 at ...e4e11a069a923db36ac6ad39eba022/user/plugins/lsp/init.lua:780

Wed Nov  8 01:43:07 2023 [INFO] [LSP/pylsp]: Sent request 'textDocument/hover':
{"method":"textDocument/hover","params":{"textDocument":{"uri":"file:///...../test_pylsp.py"},"position":{"character":7,"line":8}},"jsonrpc":"2.0","id":8}
 at ...e4e11a069a923db36ac6ad39eba022/user/plugins/lsp/init.lua:780

Wed Nov  8 01:43:07 2023 [INFO] [LSP/pylsp]: Response header and content received at once:
Content-Length: 104
Content-Type: application/vscode-jsonrpc; charset=utf8

{"jsonrpc":"2.0","id":8,"result":{"contents":{"kind":"markdown","value":"```python\nFoo()\n```\n\n\n"}}}
 at ...e4e11a069a923db36ac6ad39eba022/user/plugins/lsp/init.lua:780

Wed Nov  8 01:43:07 2023 [INFO] [LSP/pylsp]: Processing Response:
{"result":{"contents":{"value":"```python\nFoo()\n```\n\n\n","kind":"markdown"}},"jsonrpc":"2.0","id":8}
 at ...e4e11a069a923db36ac6ad39eba022/user/plugins/lsp/init.lua:780

Line 8 gets sent: 2023-11-07-231652_355x75_scrot

But Foo() is actually on Line 9

This shouldn't be a problem, as position is 0-based.

ghost commented 12 months ago

LSP: with #77 and #79 applied Lite-XL: master Jedi server: 0.41.1

And yeah. both mouse highlighting and selecting Show Symbol info from the context menu

Guldoman commented 12 months ago

Ah wait, so this is not with pylsp, but with jedi-language-server, right? If so, what's your config for it? I'll test it later.

Btw I merged both #77 and #79, so you can now just pull from master.

ghost commented 12 months ago

Yeah I dropped PyLSP as it wasn't giving me the performance I needed, auto-complete took a bit too long for my liking so I made the switch to Jedi

Configuration for jedi:

lsp.add_server {
    name = "Jedi",
    language = "Python",
    file_patterns = { "%.py$", "%.pyw$" },
    command = { "jedi-language-server" },
    init_options = {
        hover = { enable = true }
    },
    requests_per_second = 16,
    incremental_changes = false,
    verbose = true
}
Guldoman commented 12 months ago

Mmm I can't seem to reproduce the issue (sorry for the stuttery mess):

Video del 2023-11-09 00-48-18.webm

Thu Nov  9 00:55:16 2023 [INFO] [LSP/Jedi]: Adding request textDocument/hover
 at ...e4e11a069a923db36ac6ad39eba022/user/plugins/lsp/init.lua:780

Thu Nov  9 00:55:16 2023 [INFO] [LSP/Jedi]: Sent request 'textDocument/hover':
{"method":"textDocument/hover","params":{"position":{"line":8,"character":8},"textDocument":{"uri":"file:///.../test_pylsp.py"}},"id":12,"jsonrpc":"2.0"}
 at ...e4e11a069a923db36ac6ad39eba022/user/plugins/lsp/init.lua:780

Thu Nov  9 00:55:16 2023 [INFO] [LSP/Jedi]: Response header and content received at once:
Content-Length: 216
Content-Type: application/vscode-jsonrpc; charset=utf-8

{"id": 12, "jsonrpc": "2.0", "result": {"contents": {"kind": "plaintext", "value": "class Foo()\n---\nFull name: test_pylsp.Foo"}, "range": {"start": {"line": 8, "character": 6}, "end": {"line": 8, "character": 9}}}}
 at ...e4e11a069a923db36ac6ad39eba022/user/plugins/lsp/init.lua:780

Thu Nov  9 00:55:16 2023 [INFO] [LSP/Jedi]: Processing Response:
{"result":{"contents":{"kind":"plaintext","value":"class Foo()\n---\nFull name: test_pylsp.Foo"},"range":{"start":{"line":8,"character":6},"end":{"line":8,"character":9}}},"id":12,"jsonrpc":"2.0"}
 at ...e4e11a069a923db36ac6ad39eba022/user/plugins/lsp/init.lua:780

Am I missing something? Any custom config in the user module?

I'm testing both Lite XL master and 2.1.1, LSP master, jedi-language-server 0.41.1.

ghost commented 12 months ago

My full Lite-XL configuration can be found here

Guldoman commented 12 months ago

I cloned all the libraries and plugins at the commits indicated by the submodules in your repo, but it still worked fine. I also tried with an empty file, and pasting the snippet and hovering without first saving.

I wonder if this is a jedi issue, or a python env issue.

ghost commented 12 months ago

Just tested it using a new directory, still the same error.

I'll try using PyLSP and Pyright, and see if I can recreate it

Guldoman commented 12 months ago

Could you also check if other editors have the same issue with jedi?

ghost commented 12 months ago

Will do

VSCodium (flatpak) is completely broken for some reason, and just wrecks my CPU. I'll see if I can setup NeoVim with the LSP plugins

ghost commented 12 months ago

Just did a complete nuke of Lite-XL, and somehow it fixed it.

Maybe my package manager didn't do a proper job of cleaning up leftover files after I removed the original Lite-XL to compile the master myself.

Very strange, but the issue is fixed anyways

ghost commented 12 months ago

Nevermind, still having the issue. It does work for functions tho. What?

ghost commented 12 months ago

Some more logs:

Thu Nov  9 22:27:18 2023 [INFO] [LSP/Jedi]: Processing Response:
{"jsonrpc":"2.0","error":{"message":"EOFError: Ran out of input","data":"{'traceback': ['  File \"/home/user/.local/lib/python3.11/site-packages/pygls/protocol/json_rpc.py\", line 265, in _handle_request\\n    self._execute_request(msg_id, handler, params)\\n', '  File \"/home/user/.local/lib/python3.11/site-packages/pygls/protocol/json_rpc.py\", line 187, in _execute_request\\n    self._send_response(msg_id, handler(params))\\n                                ^^^^^^^^^^^^^^^\\n', '  File \"/home/user/.local/lib/python3.11/site-packages/jedi_language_server/server.py\", line 383, in hover\\n    hover_text = jedi_utils.hover_text(\\n                 ^^^^^^^^^^^^^^^^^^^^^^\\n', '  File \"/home/user/.local/lib/python3.11/site-packages/jedi_language_server/jedi_utils.py\", line 665, in hover_text\\n    header_plain = \"\\\\n\".join(get_full_signatures(name))\\n                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\\n', '  File \"/home/user/.local/lib/python3.11/site-packages/jedi_language_server/jedi_utils.py\", line 609, in get_full_signatures\\n    signatures = name.get_signatures()\\n                 ^^^^^^^^^^^^^^^^^^^^^\\n', '  File \"/home/user/.local/lib/python3.11/site-packages/jedi/api/classes.py\", line 581, in get_signatures\\n    for s in self._get_signatures()\\n             ^^^^^^^^^^^^^^^^^^^^^^\\n', '  File \"/home/user/.local/lib/python3.11/site-packages/jedi/api/classes.py\", line 570, in _get_signatures\\n    return [sig for name in names for sig in name.infer().get_signatures()]\\n           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\\n', '  File \"/home/user/.local/lib/python3.11/site-packages/jedi/api/classes.py\", line 570, in <listcomp>\\n    return [sig for name in names for sig in name.infer().get_signatures()]\\n                                             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\\n', '  File \"/home/user/.local/lib/python3.11/site-packages/jedi/inference/base_value.py\", line 516, in get_signatures\\n    return [sig for c in self._set for sig in c.get_signatures()]\\n           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\\n', '  File \"/home/user/.local/lib/python3.11/site-packages/jedi/inference/base_value.py\", line 516, in <listcomp>\\n    return [sig for c in self._set for sig in c.get_signatures()]\\n                                              ^^^^^^^^^^^^^^^^^^\\n', '  File \"/home/user/.local/lib/python3.11/site-packages/jedi/inference/value/klass.py\", line 228, in get_signatures\\n    metaclasses = self.get_metaclasses()\\n                  ^^^^^^^^^^^^^^^^^^^^^^\\n', '  File \"/home/user/.local/lib/python3.11/site-packages/jedi/inference/cache.py\", line 44, in wrapper\\n    rv = function(obj, *args, **kwargs)\\n         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\\n', '  File \"/home/user/.local/lib/python3.11/site-packages/jedi/inference/value/klass.py\", line 380, in get_metaclasses\\n    for lazy_base in self.py__bases__():\\n                     ^^^^^^^^^^^^^^^^^^\\n', '  File \"/home/user/.local/lib/python3.11/site-packages/jedi/inference/cache.py\", line 44, in wrapper\\n    rv = function(obj, *args, **kwargs)\\n         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\\n', '  File \"/home/user/.local/lib/python3.11/site-packages/jedi/inference/value/klass.py\", line 362, in py__bases__\\n    self.inference_state.builtins_module.py__getattribute__(\\'object\\')\\n    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\\n', '  File \"/home/user/.local/lib/python3.11/site-packages/jedi/inference/cache.py\", line 44, in wrapper\\n    rv = function(obj, *args, **kwargs)\\n         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\\n', '  File \"/home/user/.local/lib/python3.11/site-packages/jedi/inference/__init__.py\", line 129, in builtins_module\\n    builtins_module, = self.import_module((module_name,), sys_path=[])\\n                       ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\\n', '  File \"/home/user/.local/lib/python3.11/site-packages/jedi/inference/__init__.py\", line 112, in import_module\\n    return imports.import_module_by_names(\\n           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\\n', '  File \"/home/user/.local/lib/python3.11/site-packages/jedi/inference/imports.py\", line 376, in import_module_by_names\\n    value_set = ValueSet.from_sets([\\n                                   ^\\n', '  File \"/home/user/.local/lib/python3.11/site-packages/jedi/inference/imports.py\", line 377, in <listcomp>\\n    import_module(\\n', '  File \"/home/user/.local/lib/python3.11/site-packages/jedi/plugins/__init__.py\", line 21, in wrapper\\n    return built_functions[public_name](*args, **kwargs)\\n           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\\n', '  File \"/home/user/.local/lib/python3.11/site-packages/jedi/plugins/flask.py\", line 20, in wrapper\\n    return callback(inference_state, import_names, module_context, *args, **kwargs)\\n           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\\n', '  File \"/home/user/.local/lib/python3.11/site-packages/jedi/inference/gradual/typeshed.py\", line 124, in wrapper\\n    stub = try_to_load_stub_cached(inference_state, import_names, python_value_set,\\n           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\\n', '  File \"/home/user/.local/lib/python3.11/site-packages/jedi/inference/gradual/typeshed.py\", line 146, in try_to_load_stub_cached\\n    _try_to_load_stub(inference_state, import_names, *args, **kwargs)\\n', '  File \"/home/user/.local/lib/python3.11/site-packages/jedi/inference/gradual/typeshed.py\", line 213, in _try_to_load_stub\\n    m = _load_from_typeshed(inference_state, python_value_set, parent_module_value, import_names)\\n        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\\n', '  File \"/home/user/.local/lib/python3.11/site-packages/jedi/inference/gradual/typeshed.py\", line 263, in _load_from_typeshed\\n    return _try_to_load_stub_from_file(\\n           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^\\n', '  File \"/home/user/.local/lib/python3.11/site-packages/jedi/inference/gradual/typeshed.py\", line 273, in _try_to_load_stub_from_file\\n    stub_module_node = parse_stub_module(inference_state, file_io)\\n                       ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\\n', '  File \"/home/user/.local/lib/python3.11/site-packages/jedi/inference/gradual/typeshed.py\", line 285, in parse_stub_module\\n    return inference_state.parse(\\n           ^^^^^^^^^^^^^^^^^^^^^^\\n', '  File \"/home/user/.local/lib/python3.11/site-packages/jedi/inference/__init__.py\", line 199, in parse\\n    return self.parse_and_get_code(*args, **kwargs)[0]\\n           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\\n', '  File \"/home/user/.local/lib/python3.11/site-packages/jedi/inference/__init__.py\", line 196, in parse_and_get_code\\n    return grammar.parse(code=code, path=path, file_io=file_io, **kwargs), code\\n           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\\n', '  File \"/home/user/.local/lib/python3.11/site-packages/parso/grammar.py\", line 114, in parse\\n    module_node = load_module(self._hashed, file_io, cache_path=cache_path)\\n                  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\\n', '  File \"/home/user/.local/lib/python3.11/site-packages/parso/cache.py\", line 127, in load_module\\n    return _load_from_file_system(\\n           ^^^^^^^^^^^^^^^^^^^^^^^\\n', '  File \"/home/user/.local/lib/python3.11/site-packages/parso/cache.py\", line 145, in _load_from_file_system\\n    module_cache_item = pickle.load(f)\\n                        ^^^^^^^^^^^^^^\\n']}","code":-32603},"id":3}
 at /home/user/.config/lite-xl/plugins/lsp/init.lua:780

Thu Nov  9 22:27:18 2023 [INFO] [LSP/Jedi]: Response header and content received at once:
Content-Length: 7642
Content-Type: application/vscode-jsonrpc; charset=utf-8

{"error": {"code": -32603, "message": "EOFError: Ran out of input", "data": "{'traceback': ['  File \"/home/user/.local/lib/python3.11/site-packages/pygls/protocol/json_rpc.py\", line 265, in _handle_request\\n    self._execute_request(msg_id, handler, params)\\n', '  File \"/home/user/.local/lib/python3.11/site-packages/pygls/protocol/json_rpc.py\", line 187, in _execute_request\\n    self._send_response(msg_id, handler(params))\\n                                ^^^^^^^^^^^^^^^\\n', '  File \"/home/user/.local/lib/python3.11/site-packages/jedi_language_server/server.py\", line 383, in hover\\n    hover_text = jedi_utils.hover_text(\\n                 ^^^^^^^^^^^^^^^^^^^^^^\\n', '  File \"/home/user/.local/lib/python3.11/site-packages/jedi_language_server/jedi_utils.py\", line 665, in hover_text\\n    header_plain = \"\\\\n\".join(get_full_signatures(name))\\n                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\\n', '  File \"/home/user/.local/lib/python3.11/site-packages/jedi_language_server/jedi_utils.py\", line 609, in get_full_signatures\\n    signatures = name.get_signatures()\\n                 ^^^^^^^^^^^^^^^^^^^^^\\n', '  File \"/home/user/.local/lib/python3.11/site-packages/jedi/api/classes.py\", line 581, in get_signatures\\n    for s in self._get_signatures()\\n             ^^^^^^^^^^^^^^^^^^^^^^\\n', '  File \"/home/user/.local/lib/python3.11/site-packages/jedi/api/classes.py\", line 570, in _get_signatures\\n    return [sig for name in names for sig in name.infer().get_signatures()]\\n           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\\n', '  File \"/home/user/.local/lib/python3.11/site-packages/jedi/api/classes.py\", line 570, in <listcomp>\\n    return [sig for name in names for sig in name.infer().get_signatures()]\\n                                             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\\n', '  File \"/home/user/.local/lib/python3.11/site-packages/jedi/inference/base_value.py\", line 516, in get_signatures\\n    return [sig for c in self._set for sig in c.get_signatures()]\\n           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\\n', '  File \"/home/user/.local/lib/python3.11/site-packages/jedi/inference/base_value.py\", line 516, in <listcomp>\\n    return [sig for c in self._set for sig in c.get_signatures()]\\n                                              ^^^^^^^^^^^^^^^^^^\\n', '  File \"/home/user/.local/lib/python3.11/site-packages/jedi/inference/value/klass.py\", line 228, in get_signatures\\n    metaclasses = self.get_metaclasses()\\n                  ^^^^^^^^^^^^^^^^^^^^^^\\n', '  File \"/home/user/.local/lib/python3.11/site-packages/jedi/inference/cache.py\", line 44, in wrapper\\n    rv = function(obj, *args, **kwargs)\\n         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\\n', '  File \"/home/user/.local/lib/python3.11/site-packages/jedi/inference/value/klass.py\", line 380, in get_metaclasses\\n    for lazy_base in self.py__bases__():\\n                     ^^^^^^^^^^^^^^^^^^\\n', '  File \"/home/user/.local/lib/python3.11/site-packages/jedi/inference/cache.py\", line 44, in wrapper\\n    rv = function(obj, *args, **kwargs)\\n         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\\n', '  File \"/home/user/.local/lib/python3.11/site-packages/jedi/inference/value/klass.py\", line 362, in py__bases__\\n    self.inference_state.builtins_module.py__getattribute__(\\'object\\')\\n    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\\n', '  File \"/home/user/.local/lib/python3.11/site-packages/jedi/inference/cache.py\", line 44, in wrapper\\n    rv = function(obj, *args, **kwargs)\\n         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\\n', '  File \"/home/user/.local/lib/python3.11/site-packages/jedi/inference/__init__.py\", line 129, in builtins_module\\n    builtins_module, = self.import_module((module_name,), sys_path=[])\\n                       ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\\n', '  File \"/home/user/.local/lib/python3.11/site-packages/jedi/inference/__init__.py\", line 112, in import_module\\n    return imports.import_module_by_names(\\n           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\\n', '  File \"/home/user/.local/lib/python3.11/site-packages/jedi/inference/imports.py\", line 376, in import_module_by_names\\n    value_set = ValueSet.from_sets([\\n                                   ^\\n', '  File \"/home/user/.local/lib/python3.11/site-packages/jedi/inference/imports.py\", line 377, in <listcomp>\\n    import_module(\\n', '  File \"/home/user/.local/lib/python3.11/site-packages/jedi/plugins/__init__.py\", line 21, in wrapper\\n    return built_functions[public_name](*args, **kwargs)\\n           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\\n', '  File \"/home/user/.local/lib/python3.11/site-packages/jedi/plugins/flask.py\", line 20, in wrapper\\n    return callback(inference_state, import_names, module_context, *args, **kwargs)\\n           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\\n', '  File \"/home/user/.local/lib/python3.11/site-packages/jedi/inference/gradual/typeshed.py\", line 124, in wrapper\\n    stub = try_to_load_stub_cached(inference_state, import_names, python_value_set,\\n           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\\n', '  File \"/home/user/.local/lib/python3.11/site-packages/jedi/inference/gradual/typeshed.py\", line 146, in try_to_load_stub_cached\\n    _try_to_load_stub(inference_state, import_names, *args, **kwargs)\\n', '  File \"/home/user/.local/lib/python3.11/site-packages/jedi/inference/gradual/typeshed.py\", line 213, in _try_to_load_stub\\n    m = _load_from_typeshed(inference_state, python_value_set, parent_module_value, import_names)\\n        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\\n', '  File \"/home/user/.local/lib/python3.11/site-packages/jedi/inference/gradual/typeshed.py\", line 263, in _load_from_typeshed\\n    return _try_to_load_stub_from_file(\\n           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^\\n', '  File \"/home/user/.local/lib/python3.11/site-packages/jedi/inference/gradual/typeshed.py\", line 273, in _try_to_load_stub_from_file\\n    stub_module_node = parse_stub_module(inference_state, file_io)\\n                       ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\\n', '  File \"/home/user/.local/lib/python3.11/site-packages/jedi/inference/gradual/typeshed.py\", line 285, in parse_stub_module\\n    return inference_state.parse(\\n           ^^^^^^^^^^^^^^^^^^^^^^\\n', '  File \"/home/user/.local/lib/python3.11/site-packages/jedi/inference/__init__.py\", line 199, in parse\\n    return self.parse_and_get_code(*args, **kwargs)[0]\\n           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\\n', '  File \"/home/user/.local/lib/python3.11/site-packages/jedi/inference/__init__.py\", line 196, in parse_and_get_code\\n    return grammar.parse(code=code, path=path, file_io=file_io, **kwargs), code\\n           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\\n', '  File \"/home/user/.local/lib/python3.11/site-packages/parso/grammar.py\", line 114, in parse\\n    module_node = load_module(self._hashed, file_io, cache_path=cache_path)\\n                  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\\n', '  File \"/home/user/.local/lib/python3.11/site-packages/parso/cache.py\", line 127, in load_module\\n    return _load_from_file_system(\\n           ^^^^^^^^^^^^^^^^^^^^^^^\\n', '  File \"/home/user/.local/lib/python3.11/site-packages/parso/cache.py\", line 145, in _load_from_file_system\\n    module_cache_item = pickle.load(f)\\n                        ^^^^^^^^^^^^^^\\n']}"}, "jsonrpc": "2.0", "id": 3}
 at /home/user/.config/lite-xl/plugins/lsp/init.lua:780

Thu Nov  9 22:27:18 2023 [INFO] [LSP/Jedi]: Sent request 'textDocument/hover':
{"jsonrpc":"2.0","params":{"position":{"line":22,"character":7},"textDocument":{"uri":"file:///home/user/Documents/Code/testing/test.py"}},"id":3,"method":"textDocument/hover"}
 at /home/user/.config/lite-xl/plugins/lsp/init.lua:780

Thu Nov  9 22:27:18 2023 [INFO] [LSP/Jedi]: Adding request textDocument/hover
 at /home/user/.config/lite-xl/plugins/lsp/init.lua:780

Thu Nov  9 22:26:56 2023 [INFO] [LSP/Jedi]: Processing Response:
{"jsonrpc":"2.0","id":2,"result":{"range":{"start":{"line":15,"character":4},"end":{"line":15,"character":10}},"contents":{"kind":"plaintext","value":"def foobar()\n---\nA function that does something\nFull name: testing.test.foobar"}}}
 at /home/user/.config/lite-xl/plugins/lsp/init.lua:780

Thu Nov  9 22:26:56 2023 [INFO] [LSP/Jedi]: Response header and content received at once:
Content-Length: 256
Content-Type: application/vscode-jsonrpc; charset=utf-8

{"id": 2, "jsonrpc": "2.0", "result": {"contents": {"kind": "plaintext", "value": "def foobar()\n---\nA function that does something\nFull name: testing.test.foobar"}, "range": {"start": {"line": 15, "character": 4}, "end": {"line": 15, "character": 10}}}}
 at /home/user/.config/lite-xl/plugins/lsp/init.lua:780

Thu Nov  9 22:26:55 2023 [INFO] [LSP/Jedi]: Sent request 'textDocument/hover':
{"jsonrpc":"2.0","params":{"position":{"line":15,"character":8},"textDocument":{"uri":"file:///home/user/Documents/Code/testing/test.py"}},"id":2,"method":"textDocument/hover"}
 at /home/user/.config/lite-xl/plugins/lsp/init.lua:780

Thu Nov  9 22:26:55 2023 [INFO] [LSP/Jedi]: Adding request textDocument/hover
 at /home/user/.config/lite-xl/plugins/lsp/init.lua:780

New snippet to test with:

class Foo():
    """
    A class that does something
    """

    def __init__(self):
        self.name = "foo"

    def my_name(self):
        """
        Returns a name
        """

        return self.name

def foobar():
    """
    A function that does something
    """

    return 123

foo = Foo()
print(foo.my_name())
print(foobar())
Guldoman commented 12 months ago

Try following these steps:

  1. mkdir /tmp/test_jedi
  2. cd /tmp/test_jedi
  3. cat << EOF > test_jedi.py
    class Foo():
       """
       A class that does something
       """
    
       def __init__(self):
           self.name = "foo"
    
       def my_name(self):
           """
           Returns a name
           """
    
           return self.name
    
    def foobar():
       """
       A function that does something
       """
    
       return 123
    
    foo = Foo()
    print(foo.my_name())
    print(foobar())
    EOF
  4. wget -O jedi_session https://github.com/lite-xl/lite-xl-lsp/files/13313762/jedi_session.txt
  5. cat jedi_session | jedi-language-server

My output is:

Content-Length: 862
Content-Type: application/vscode-jsonrpc; charset=utf-8

{"id": 1, "jsonrpc": "2.0", "result": {"capabilities": {"positionEncoding": "utf-16", "textDocumentSync": {"openClose": true, "change": 2, "save": true}, "completionProvider": {"triggerCharacters": [".", "'", "\""], "resolveProvider": true}, "hoverProvider": true, "signatureHelpProvider": {"triggerCharacters": ["(", ","]}, "definitionProvider": true, "typeDefinitionProvider": {}, "referencesProvider": true, "documentHighlightProvider": true, "documentSymbolProvider": true, "codeActionProvider": {"codeActionKinds": ["refactor.inline", "refactor.extract"]}, "workspaceSymbolProvider": {"resolveProvider": false}, "renameProvider": true, "executeCommandProvider": {"commands": []}, "workspace": {"workspaceFolders": {"supported": true, "changeNotifications": true}, "fileOperations": {}}}, "serverInfo": {"name": "jedi-language-server", "version": "0.19.1"}}}Content-Length: 245
Content-Type: application/vscode-jsonrpc; charset=utf-8

{"id": 2, "jsonrpc": "2.0", "result": {"contents": {"kind": "plaintext", "value": "class Foo()\n---\nA class that does something\nFull name: test_jedi.Foo"}, "range": {"start": {"line": 22, "character": 6}, "end": {"line": 22, "character": 9}}}}Content-Length: 139
Content-Type: application/vscode-jsonrpc; charset=utf-8

{"params": {"uri": "file:///tmp/test_jedi/test_jedi.py", "diagnostics": []}, "method": "textDocument/publishDiagnostics", "jsonrpc": "2.0"}Content-Length: 43
Content-Type: application/vscode-jsonrpc; charset=utf-8

{"id": 3, "jsonrpc": "2.0", "result": null}

Do you get errors even when simulating a session like this?

ghost commented 12 months ago

Yup, still the same errors:

Content-Length: 862
Content-Type: application/vscode-jsonrpc; charset=utf-8

{"id": 1, "jsonrpc": "2.0", "result": {"capabilities": {"positionEncoding": "utf-16", "textDocumentSync": {"openClose": true, "change": 2, "save": true}, "completionProvider": {"triggerCharacters": [".", "'", "\""], "resolveProvider": true}, "hoverProvider": true, "signatureHelpProvider": {"triggerCharacters": ["(", ","]}, "definitionProvider": true, "typeDefinitionProvider": {}, "referencesProvider": true, "documentHighlightProvider": true, "documentSymbolProvider": true, "codeActionProvider": {"codeActionKinds": ["refactor.inline", "refactor.extract"]}, "workspaceSymbolProvider": {"resolveProvider": false}, "renameProvider": true, "executeCommandProvider": {"commands": []}, "workspace": {"workspaceFolders": {"supported": true, "changeNotifications": true}, "fileOperations": {}}}, "serverInfo": {"name": "jedi-language-server", "version": "0.19.1"}}}ERROR:pygls.protocol.json_rpc:Failed to handle request 2 textDocument/hover HoverParams(text_document=TextDocumentIdentifier(uri='file:///tmp/test_jedi/test_jedi.py'), position=22:8, work_done_token=None)
Traceback (most recent call last):
  File "/home/user/.local/lib/python3.11/site-packages/parso/cache.py", line 122, in load_module
    module_cache_item = parser_cache[hashed_grammar][file_io.path]
                        ~~~~~~~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^
KeyError: PosixPath('/home/user/.local/lib/python3.11/site-packages/jedi/third_party/typeshed/stdlib/3/builtins.pyi')

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/home/user/.local/lib/python3.11/site-packages/pygls/protocol/json_rpc.py", line 265, in _handle_request
    self._execute_request(msg_id, handler, params)
  File "/home/user/.local/lib/python3.11/site-packages/pygls/protocol/json_rpc.py", line 187, in _execute_request
    self._send_response(msg_id, handler(params))
                                ^^^^^^^^^^^^^^^
  File "/home/user/.local/lib/python3.11/site-packages/jedi_language_server/server.py", line 383, in hover
    hover_text = jedi_utils.hover_text(
                 ^^^^^^^^^^^^^^^^^^^^^^
  File "/home/user/.local/lib/python3.11/site-packages/jedi_language_server/jedi_utils.py", line 665, in hover_text
    header_plain = "\n".join(get_full_signatures(name))
                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/user/.local/lib/python3.11/site-packages/jedi_language_server/jedi_utils.py", line 609, in get_full_signatures
    signatures = name.get_signatures()
                 ^^^^^^^^^^^^^^^^^^^^^
  File "/home/user/.local/lib/python3.11/site-packages/jedi/api/classes.py", line 581, in get_signatures
    for s in self._get_signatures()
             ^^^^^^^^^^^^^^^^^^^^^^
  File "/home/user/.local/lib/python3.11/site-packages/jedi/api/classes.py", line 570, in _get_signatures
    return [sig for name in names for sig in name.infer().get_signatures()]
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/user/.local/lib/python3.11/site-packages/jedi/api/classes.py", line 570, in <listcomp>
    return [sig for name in names for sig in name.infer().get_signatures()]
                                             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/user/.local/lib/python3.11/site-packages/jedi/inference/base_value.py", line 516, in get_signatures
    return [sig for c in self._set for sig in c.get_signatures()]
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/user/.local/lib/python3.11/site-packages/jedi/inference/base_value.py", line 516, in <listcomp>
    return [sig for c in self._set for sig in c.get_signatures()]
                                              ^^^^^^^^^^^^^^^^^^
  File "/home/user/.local/lib/python3.11/site-packages/jedi/inference/value/klass.py", line 228, in get_signatures
    metaclasses = self.get_metaclasses()
                  ^^^^^^^^^^^^^^^^^^^^^^
  File "/home/user/.local/lib/python3.11/site-packages/jedi/inference/cache.py", line 44, in wrapper
    rv = function(obj, *args, **kwargs)
         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/user/.local/lib/python3.11/site-packages/jedi/inference/value/klass.py", line 380, in get_metaclasses
    for lazy_base in self.py__bases__():
                     ^^^^^^^^^^^^^^^^^^
  File "/home/user/.local/lib/python3.11/site-packages/jedi/inference/cache.py", line 44, in wrapper
    rv = function(obj, *args, **kwargs)
         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/user/.local/lib/python3.11/site-packages/jedi/inference/value/klass.py", line 362, in py__bases__
    self.inference_state.builtins_module.py__getattribute__('object')
    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/user/.local/lib/python3.11/site-packages/jedi/inference/cache.py", line 44, in wrapper
    rv = function(obj, *args, **kwargs)
         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/user/.local/lib/python3.11/site-packages/jedi/inference/__init__.py", line 129, in builtins_module
    builtins_module, = self.import_module((module_name,), sys_path=[])
                       ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/user/.local/lib/python3.11/site-packages/jedi/inference/__init__.py", line 112, in import_module
    return imports.import_module_by_names(
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/user/.local/lib/python3.11/site-packages/jedi/inference/imports.py", line 376, in import_module_by_names
    value_set = ValueSet.from_sets([
                                   ^
  File "/home/user/.local/lib/python3.11/site-packages/jedi/inference/imports.py", line 377, in <listcomp>
    import_module(
  File "/home/user/.local/lib/python3.11/site-packages/jedi/plugins/__init__.py", line 21, in wrapper
    return built_functions[public_name](*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/user/.local/lib/python3.11/site-packages/jedi/plugins/flask.py", line 20, in wrapper
    return callback(inference_state, import_names, module_context, *args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/user/.local/lib/python3.11/site-packages/jedi/inference/gradual/typeshed.py", line 124, in wrapper
    stub = try_to_load_stub_cached(inference_state, import_names, python_value_set,
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/user/.local/lib/python3.11/site-packages/jedi/inference/gradual/typeshed.py", line 146, in try_to_load_stub_cached
    _try_to_load_stub(inference_state, import_names, *args, **kwargs)
  File "/home/user/.local/lib/python3.11/site-packages/jedi/inference/gradual/typeshed.py", line 213, in _try_to_load_stub
    m = _load_from_typeshed(inference_state, python_value_set, parent_module_value, import_names)
        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/user/.local/lib/python3.11/site-packages/jedi/inference/gradual/typeshed.py", line 263, in _load_from_typeshed
    return _try_to_load_stub_from_file(
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/user/.local/lib/python3.11/site-packages/jedi/inference/gradual/typeshed.py", line 273, in _try_to_load_stub_from_file
    stub_module_node = parse_stub_module(inference_state, file_io)
                       ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/user/.local/lib/python3.11/site-packages/jedi/inference/gradual/typeshed.py", line 285, in parse_stub_module
    return inference_state.parse(
           ^^^^^^^^^^^^^^^^^^^^^^
  File "/home/user/.local/lib/python3.11/site-packages/jedi/inference/__init__.py", line 199, in parse
    return self.parse_and_get_code(*args, **kwargs)[0]
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/user/.local/lib/python3.11/site-packages/jedi/inference/__init__.py", line 196, in parse_and_get_code
    return grammar.parse(code=code, path=path, file_io=file_io, **kwargs), code
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/user/.local/lib/python3.11/site-packages/parso/grammar.py", line 114, in parse
    module_node = load_module(self._hashed, file_io, cache_path=cache_path)
                  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/user/.local/lib/python3.11/site-packages/parso/cache.py", line 127, in load_module
    return _load_from_file_system(
           ^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/user/.local/lib/python3.11/site-packages/parso/cache.py", line 145, in _load_from_file_system
    module_cache_item = pickle.load(f)
                        ^^^^^^^^^^^^^^
EOFError: Ran out of input
Content-Length: 7642
Content-Type: application/vscode-jsonrpc; charset=utf-8

{"error": {"code": -32603, "message": "EOFError: Ran out of input", "data": "{'traceback': ['  File \"/home/user/.local/lib/python3.11/site-packages/pygls/protocol/json_rpc.py\", line 265, in _handle_request\\n    self._execute_request(msg_id, handler, params)\\n', '  File \"/home/user/.local/lib/python3.11/site-packages/pygls/protocol/json_rpc.py\", line 187, in _execute_request\\n    self._send_response(msg_id, handler(params))\\n                                ^^^^^^^^^^^^^^^\\n', '  File \"/home/user/.local/lib/python3.11/site-packages/jedi_language_server/server.py\", line 383, in hover\\n    hover_text = jedi_utils.hover_text(\\n                 ^^^^^^^^^^^^^^^^^^^^^^\\n', '  File \"/home/user/.local/lib/python3.11/site-packages/jedi_language_server/jedi_utils.py\", line 665, in hover_text\\n    header_plain = \"\\\\n\".join(get_full_signatures(name))\\n                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\\n', '  File \"/home/user/.local/lib/python3.11/site-packages/jedi_language_server/jedi_utils.py\", line 609, in get_full_signatures\\n    signatures = name.get_signatures()\\n                 ^^^^^^^^^^^^^^^^^^^^^\\n', '  File \"/home/user/.local/lib/python3.11/site-packages/jedi/api/classes.py\", line 581, in get_signatures\\n    for s in self._get_signatures()\\n             ^^^^^^^^^^^^^^^^^^^^^^\\n', '  File \"/home/user/.local/lib/python3.11/site-packages/jedi/api/classes.py\", line 570, in _get_signatures\\n    return [sig for name in names for sig in name.infer().get_signatures()]\\n           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\\n', '  File \"/home/user/.local/lib/python3.11/site-packages/jedi/api/classes.py\", line 570, in <listcomp>\\n    return [sig for name in names for sig in name.infer().get_signatures()]\\n                                             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\\n', '  File \"/home/user/.local/lib/python3.11/site-packages/jedi/inference/base_value.py\", line 516, in get_signatures\\n    return [sig for c in self._set for sig in c.get_signatures()]\\n           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\\n', '  File \"/home/user/.local/lib/python3.11/site-packages/jedi/inference/base_value.py\", line 516, in <listcomp>\\n    return [sig for c in self._set for sig in c.get_signatures()]\\n                                              ^^^^^^^^^^^^^^^^^^\\n', '  File \"/home/user/.local/lib/python3.11/site-packages/jedi/inference/value/klass.py\", line 228, in get_signatures\\n    metaclasses = self.get_metaclasses()\\n                  ^^^^^^^^^^^^^^^^^^^^^^\\n', '  File \"/home/user/.local/lib/python3.11/site-packages/jedi/inference/cache.py\", line 44, in wrapper\\n    rv = function(obj, *args, **kwargs)\\n         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\\n', '  File \"/home/user/.local/lib/python3.11/site-packages/jedi/inference/value/klass.py\", line 380, in get_metaclasses\\n    for lazy_base in self.py__bases__():\\n                     ^^^^^^^^^^^^^^^^^^\\n', '  File \"/home/user/.local/lib/python3.11/site-packages/jedi/inference/cache.py\", line 44, in wrapper\\n    rv = function(obj, *args, **kwargs)\\n         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\\n', '  File \"/home/user/.local/lib/python3.11/site-packages/jedi/inference/value/klass.py\", line 362, in py__bases__\\n    self.inference_state.builtins_module.py__getattribute__(\\'object\\')\\n    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\\n', '  File \"/home/user/.local/lib/python3.11/site-packages/jedi/inference/cache.py\", line 44, in wrapper\\n    rv = function(obj, *args, **kwargs)\\n         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\\n', '  File \"/home/user/.local/lib/python3.11/site-packages/jedi/inference/__init__.py\", line 129, in builtins_module\\n    builtins_module, = self.import_module((module_name,), sys_path=[])\\n                       ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\\n', '  File \"/home/user/.local/lib/python3.11/site-packages/jedi/inference/__init__.py\", line 112, in import_module\\n    return imports.import_module_by_names(\\n           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\\n', '  File \"/home/user/.local/lib/python3.11/site-packages/jedi/inference/imports.py\", line 376, in import_module_by_names\\n    value_set = ValueSet.from_sets([\\n                                   ^\\n', '  File \"/home/user/.local/lib/python3.11/site-packages/jedi/inference/imports.py\", line 377, in <listcomp>\\n    import_module(\\n', '  File \"/home/user/.local/lib/python3.11/site-packages/jedi/plugins/__init__.py\", line 21, in wrapper\\n    return built_functions[public_name](*args, **kwargs)\\n           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\\n', '  File \"/home/user/.local/lib/python3.11/site-packages/jedi/plugins/flask.py\", line 20, in wrapper\\n    return callback(inference_state, import_names, module_context, *args, **kwargs)\\n           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\\n', '  File \"/home/user/.local/lib/python3.11/site-packages/jedi/inference/gradual/typeshed.py\", line 124, in wrapper\\n    stub = try_to_load_stub_cached(inference_state, import_names, python_value_set,\\n           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\\n', '  File \"/home/user/.local/lib/python3.11/site-packages/jedi/inference/gradual/typeshed.py\", line 146, in try_to_load_stub_cached\\n    _try_to_load_stub(inference_state, import_names, *args, **kwargs)\\n', '  File \"/home/user/.local/lib/python3.11/site-packages/jedi/inference/gradual/typeshed.py\", line 213, in _try_to_load_stub\\n    m = _load_from_typeshed(inference_state, python_value_set, parent_module_value, import_names)\\n        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\\n', '  File \"/home/user/.local/lib/python3.11/site-packages/jedi/inference/gradual/typeshed.py\", line 263, in _load_from_typeshed\\n    return _try_to_load_stub_from_file(\\n           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^\\n', '  File \"/home/user/.local/lib/python3.11/site-packages/jedi/inference/gradual/typeshed.py\", line 273, in _try_to_load_stub_from_file\\n    stub_module_node = parse_stub_module(inference_state, file_io)\\n                       ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\\n', '  File \"/home/user/.local/lib/python3.11/site-packages/jedi/inference/gradual/typeshed.py\", line 285, in parse_stub_module\\n    return inference_state.parse(\\n           ^^^^^^^^^^^^^^^^^^^^^^\\n', '  File \"/home/user/.local/lib/python3.11/site-packages/jedi/inference/__init__.py\", line 199, in parse\\n    return self.parse_and_get_code(*args, **kwargs)[0]\\n           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\\n', '  File \"/home/user/.local/lib/python3.11/site-packages/jedi/inference/__init__.py\", line 196, in parse_and_get_code\\n    return grammar.parse(code=code, path=path, file_io=file_io, **kwargs), code\\n           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\\n', '  File \"/home/user/.local/lib/python3.11/site-packages/parso/grammar.py\", line 114, in parse\\n    module_node = load_module(self._hashed, file_io, cache_path=cache_path)\\n                  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\\n', '  File \"/home/user/.local/lib/python3.11/site-packages/parso/cache.py\", line 127, in load_module\\n    return _load_from_file_system(\\n           ^^^^^^^^^^^^^^^^^^^^^^^\\n', '  File \"/home/user/.local/lib/python3.11/site-packages/parso/cache.py\", line 145, in _load_from_file_system\\n    module_cache_item = pickle.load(f)\\n                        ^^^^^^^^^^^^^^\\n']}"}, "jsonrpc": "2.0", "id": 2}Content-Length: 139
Content-Type: application/vscode-jsonrpc; charset=utf-8

{"params": {"uri": "file:///tmp/test_jedi/test_jedi.py", "diagnostics": []}, "method": "textDocument/publishDiagnostics", "jsonrpc": "2.0"}Content-Length: 43
Content-Type: application/vscode-jsonrpc; charset=utf-8

{"id": 3, "jsonrpc": "2.0", "result": null}
Guldoman commented 12 months ago

Then I guess this is a python setup or jedi issue. I wonder if you could try installing it in a python virtual environment, and running it from there.

But yeah, you should probably just open an issue in the jedi repo, as they'll probably be able to give you better troubleshooting help.