-
Notifications
You must be signed in to change notification settings - Fork 769
This issue was moved to a discussion.
You can continue the conversation there. Go to discussion →
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
Missing (editable) Imports: But python REPL has no problems to import #6376
Comments
Please see https://microsoft.github.io/pyright/#/import-resolution?id=editable-installs. If the |
That link does not explain anything and also does not offer a solution. |
The key part of that explanation is the 'static' part. Pylance is a static analyzer. It doesn't run python code. Dynamic code in .pth files cannot be evaluated in order to find imports. That's why it doesn't work. If you use compat mode, where it writes a file path out to the .pth file, that should work. |
So pylance parse python code as text file but never runs it? |
I can't say how Pylint handles editable installs, but Pylance does not run any python code. It's not even written in Python. |
Maybe then Pylint would be a good start to investigate a solution for PyLance. I twas not clear from the previous Issues and not from docs. Do the maintainers of PyLance treat this as a real bug or is this intended behavior? When the "bug" is fixed doesn't matter at this question. Is it a bug: Yes or No? |
As of right now this issue is by design. Pylint is actually written in Python, so likely can use the import mechanism in the runtime to attempt to import packages. Pyright/Pylance are written in typescript and have to model anything the python runtime does in typescript. In the past editable installs have always been answered with use compat mode, we don't support dynamic imports, this is by design. The problem is a lot of people do editable installs so maybe it's time we support some subset of dynamic imports. The problem is that ends up exploding into essentially emulating everything the python runtime does, so we end up back with just running python to find imports. I'm going to convert this item into a discussion for up votes. |
This issue was moved to a discussion.
You can continue the conversation there. Go to discussion →
Environment data
Problem
PyLance reports
Import "buhtzology" could not be resolved...
but regular python has no problem with it. This works fine and without errors:Expected behavior
PyLance should use the same "environment" as the regular python interpreter does.
Idea
It might be the case that PyLance is not able to handle packages installed as "--editable" (via python -m pip)
The package install data can be found in the path
C:\python\Lib\site-packages\buhtzology-0.2.0.dev0.dist-info
. Inside that folder the content of fiuledirect_url.json
points to the real python file:The Python interpreter can handle that without problems. So PyLance should also.
The text was updated successfully, but these errors were encountered: