Open 0x5c opened 4 years ago
Fixed the incomplete description woops
Did you read the troubleshooting guide? https://github.com/microsoft/python-language-server/blob/master/TROUBLESHOOTING.md#unresolved-import-warnings
I now see that it is by design, but I still think this is an issue: the tools should act like python does, especially when the previous tool did, and if the new one does not come with any warnings of differing behaviour.
"Previous tool"? What do you mean?
Jedi detects those without issue.
Jedi's import resolution is much more forgiving than Python itself, and will resolve imports potentially when they won't actually work (by searching in higher directories, or next to each file). This LS takes the opposite approach, reporting errors and requiring explicit configuration of import roots.
This is a design decision we made, and aren't likely to change other than that we detect src
as a potential import root, and potential work for scripts (#1602) which are tricky in their own right because each script has a unique sys.path
depending on its invocation (and editors can't generically know how any given script will be run).
If this is mostly set in stone, then the language server should at minimum come with warnings of breaking behaviour, especially in the "Switch now!" prompt of VSCode.
Also: if Jedi is too forgiving, then the bar should be python itself. Relative imports should work, as they explicitly state the path relative to the module, which the editor knows the location of.
Modules (files or directories) in the same directory should also work, as they do in Python.
Relative imports should work fine; if that's what your issue is with then that'd be good to see. You haven't provided a layout or code, so it's hard to tell.
In the same directly only works if the files are being run as scripts from that same directory, which is not true for the vast majority of code we encounter. (Hence, #1602)
Environment data
Expected behaviour
Module is found and intellisense works (import is valid at runtime)
Actual behaviour
Import is marked at unresolved, intellisense bails out, and
Python(unresolved-import)
all over.Logs