Skip to content

MAINT: Add pyi files for modules #12047

Closed

Description

@larsoner

Just to emphasize one point from above: unless lazy loading happens in .pyi files, type checkers won't know about those functions. See:

https://scientific-python.org/specs/spec-0001/#type-checkers

Originally posted in #11780 (comment)

I wanted to separate this from #11780, I think @drammock might give it a shot?

Activity

  1. hoechenberger commented on Oct 2, 2023

    @hoechenberger
    Member

    Just to add, lazy loading currently also breaks the VS Code Python debugger (debugpy). It just throws an AttributeError and exits.

  2. larsoner commented on Oct 2, 2023

    @larsoner
    MemberAuthor

    We'll have to check to see if the .pyi file fixes this, too. If not we should raise an issue on the lazy_loader tracker after checking to see if there already is one. Seems like a caveat that should definitely be listed if it's indeed a drawback with no workaround (e.g., waiting on a vscode fix that might never come)

  3. hoechenberger commented on Oct 2, 2023

    @hoechenberger
    Member

    I can take a look at this later today or tomorrow.

    I also wanted to ask which approach we're planning to take here. We could add .pyi files inside MNE-Python, or we could add stubs to typeshed – and also slowly start adding type annotations there. I've been wanting to do that for a long time and started (and stopped) many times before.

  4. hoechenberger commented on Oct 2, 2023

    @hoechenberger
    Member

    Also see this approach for resolving the problem without adding .pyi files:
    microsoft/pylance-release#474 (comment)

  5. hoechenberger commented on Oct 2, 2023

    @hoechenberger
    Member

    Just to add, lazy loading currently also breaks the VS Code Python debugger (debugpy). It just throws an AttributeError and exits.

    Upon further inspection, this issue might actually be unrelated. I'd need to do further research to pinpoint the problem, but for now I believe it's a separate issue on my machine and not related to lazy loading.

  6. larsoner commented on Oct 2, 2023

    @larsoner
    MemberAuthor

    To me it makes sense to have .pyi to be part of this repo rather than live in typeshed

  7. drammock commented on Oct 2, 2023

    @drammock
    Member

    I can take a look at this later today or tomorrow.

    great, I'll remove myself and assign you 🙏🏻

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions