Skip to content

uv pip install -e and its PEP-660-style editable installs break vscode import resolution (and probably static type checkers) #3898

@ThiefMaster

Description

@ThiefMaster

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:

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?

Metadata

Metadata

Assignees

No one assigned

    Labels

    questionAsking for clarification or support

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions