Skip to content

feat: add attach_stub function to load imports from type stubs #10

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

Merged
merged 1 commit into from
Jul 13, 2022

Conversation

tlambert03
Copy link
Contributor

following on the discussion at scientific-python/specs#139, here is an implementation that loads imports from type stubs for your consideration

@stefanv
Copy link
Member

stefanv commented Jul 8, 2022

I like it! Does this then address all type checker concerns, or are there other outstanding ones?

I'd love for @jni and @tupui to cast an eye over this PR and share their impressions.

@tlambert03
Copy link
Contributor Author

Does this then address all type checker concerns, or are there other outstanding ones?

I think this does it. With the pyi file being the source of truth, it’s sort of a “type checking first” approach, that also works at runtime. Really I think the only downside here is that note I included about making sure the stub gets included in the wheel/sdist. I can imagine someone missing that note in the readme, having it work locally, then shipping an unimportable package (lacking the stubs)

@stefanv
Copy link
Member

stefanv commented Jul 13, 2022

Thanks very much for this @tlambert03. I'm going to merge for now, since @jni liked the implementation in scientific-python/specs#139 (comment)

It would be the cherry on top if you could also update the high level description of https://github.com/scientific-python/specs/blob/main/spec-0001/index.md (feel free to add yourself as co-author there).

@stefanv stefanv merged commit d5a3e82 into scientific-python:main Jul 13, 2022
@tlambert03 tlambert03 deleted the stub-loader branch July 13, 2022 00:52
@jarrodmillman jarrodmillman added this to the 0.1 milestone Aug 25, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants