-
Notifications
You must be signed in to change notification settings - Fork 2.9k
Description
My context is that I have a main package and some related packages. Everything is installed in editable mode for development.
When using standard pip with setuptools installed, this creates an egg-link file inside site-packages which is looked up just fine by type checkers including Pyright (which powers the vscode Python/Pylance extension).
However, when using uv pip install -e, the package is installed in PEP-660 mode with a __editable__.<pkgname+version>.pth and __editable___<pkgname+version>_finder.py, ie using a dynamic import hook.
Of course static analyzers generally do not understand those, and don't even try to extract the information from the "dynamic" code even though it would be trivial to do (by simply parsing the MAPPING dict from the ..._finder.py).
While this is not directly uv's fault, and I generally agree with not outputting legacy stuff, this is causing a problem when IDEs can no longer properly resolve imports. And at least the pyright/pylance developers don't seem to be willing to add any workarounds on their side, so they'd rather wait for the Python ecosystem to agree on something that does not require dynamic import lookups. But that probably needs someone to be willing to write a PEP and get it accepted which all takes some time.
Some related issues/comments:
- PyLance not recognizing imports from PEP-660 editable installs microsoft/pylance-release#3473 (comment)
- Editable python package available from within Python but Pyright is raising
reportMissingModuleSourcemicrosoft/pyright#3880 (comment) Import could not be resolvedwith[tool.setuptools.package-dir]microsoft/pylance-release#5894 (comment)
Is there any chance uv can do something about this, such as providing an option to generate an egg-link instead of a PEP660-style __editable__*.pth, even though it's slightly more legacy?