pappasam / jedi-language-server

A Python language server exclusively for Jedi. If Jedi supports it well, this language server should too.
MIT License
596 stars 45 forks source link

Missing warning for unresolved imports #252

Closed wtfzambo closed 1 year ago

wtfzambo commented 1 year ago

Hello,

there's a high possibility that I'm stupid, but I've been bashing my head against this for the past 4 hours without reaching any meaningful conclusion.

I use VSCode with the Microsoft Python plugin, and I recently switched to Jedi Language server because imho it parses docstrings better than PyLance does.

However, contrarily to PyLance, it doesn't warn me about unresolved imports. E.g. on a newly created python virtual environment with nothing installed:

As you can see, it doesn't warn me about pandas import not being able to resolve. Which is extra weird since Jedi is still able to resolve installed modules, as it properly shows documentation and autocomplete for them, e.g.:

image

Current specs:

What am I doing wrong?

pappasam commented 1 year ago

At this time, jedi-language-server doesn't provide those sorts of diagnostics, because Jedi does not provide them.

See here: https://github.com/pappasam/jedi-language-server#diagnostics

Related issue: https://github.com/pappasam/jedi-language-server#diagnostics

wtfzambo commented 1 year ago

Neat, thanks @pappasam , at least now I know I'm not as stupid as I thought I was.

(PS: you posted the same link twice :) )

wtfzambo commented 1 year ago

@pappasam sorry for the extra message, but I had to ask: is there a way one can use the features of Jedi and still be able to be warned about unresolved imports, or that's just impossible?

davidhalter commented 1 year ago

In theory that's probably possible, because you could use one language server for one completions and another one for diagnostics. But I feel like most editors probably did not implement that. Not sure about VSCode.

wtfzambo commented 1 year ago

@davidhalter

I noticed that Pylint seems able to report unresolved imports by itself, thanks anyway!

pappasam commented 1 year ago

@wtfzambo David's suggestion is actually how we currently recommend adding additional diagnostics: https://github.com/pappasam/jedi-language-server#diagnostics. Using a general purpose language server, you can configure pylint to provide diagnostics for Python files. One option for vscode: https://marketplace.visualstudio.com/items?itemName=Matts966.efm-langserver-vscode

Again, this is "jedi-language-server", not a kitchen-sink "Python language server". It focuses specifically on Jedi, third-party tools like pylint are out of scope for this project.

wtfzambo commented 1 year ago

thanks for the additional explanation @pappasam . To be honest, I feel like I still barely understand language servers in general, for example I'm still not sure what the difference between Jedi and Jedi Language Server is 😅