Skip to content

Referencing typeshed's own local stubs in editors #11102

Closed
@Avasam

Description

@Avasam

I've had a certain annoying pain point for quite some time with typeshed stubs.

From microsoft/pylance-release#5209 :

I'd expect absolute imports to find symbols from typeshed's own stubs, and "Go to type definition" to lead to typeshed's own .pyi (when it exists) instead of the installed library.

Here's a couple example:
image
image
When new modules get added (or a new stub gets worked on, which is full of new modules):
image

pip install types-* inside typeshed is of limited use [...]

when the stub library, or the module, doesn't exist yet. Or even if the current module is being modified in an incompatible manner (like adding generics to class).

One option is to use relative imports, but that can lead to going up many parents, and doesn't solve the issue when writing tests (all the openpyxl tests I wrote were painful because I could not trust my editor).

Another possible solution brought by Eric Traut:

[...] Perhaps you could use an editable install when developing the stub package?

I don't have the most experience working with editable installs, but that would require writing a pyproject.toml for each stub right? Could it be done dynamically with a script?

I'd love to hear thoughts and experiences from other contributors. Especially if you use different tooling than I do (VSCode+Pylance)

Ref.: #8774

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions