Skip to content
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

Add py.typed to Python package for PEP 561 compliance #3704

Merged
merged 1 commit into from
Jan 17, 2020

Conversation

csssuf
Copy link
Contributor

@csssuf csssuf commented Dec 27, 2019

PEP 561 specifies that packages which contain either inline type hints
or type stubs should indicate their support for type hints via
including a file named py.typed in the root of the package. Since
Pulumi already includes inline type hints, adding py.typed to the
Python SDK simply allows these hints to be used by mypy.

PEP 561 specifies that packages which contain either inline type hints
or type stubs should indicate their support for type hints via
including a file named `py.typed` in the root of the package. Since
Pulumi already includes inline type hints, adding `py.typed` to the
Python SDK simply allows these hints to be used by mypy.
@stack72
Copy link
Contributor

stack72 commented Dec 27, 2019

Hi @csssuf

Thanks so much for the PR here

Can you tell me what this does? I’m not a python person at all and am wondering if this needs to go into our sdk generation for all of the providers as well

Thanks

Paul

@stack72 stack72 self-assigned this Dec 27, 2019
@csssuf
Copy link
Contributor Author

csssuf commented Dec 30, 2019

Sure! Essentially, mypy won't try to read type hints from a package unless that package specifies that it supports type hints via the py.typed file added by this PR. You would want to add this to any provider packages which do have type hints as well.

@stack72
Copy link
Contributor

stack72 commented Dec 30, 2019

@csssuf thanks for the explanation - so we just need an empty file and this will work? Wow! Thanks for that :) I can add this to the system and will ping you when it's done

Thanks

Paul

@lukehoban
Copy link
Member

Btw - we should also probably run mypy in either tests or the build process to ensure that our type annotations are clean/correct relative to mypy. I don’t think we do that yet today. (And so if we turn this on for users, they may see issues we haven’t ourselves tested for).

@lukehoban
Copy link
Member

we should also probably run mypy in either tests or the build process to ensure that our type annotations are clean/correct relative to mypy

I opened #3710 to track this. We do indeed have ~150 type errors in our existing SDK because we haven't been actually running any typechecker over them to-date.

@EvanBoyle EvanBoyle mentioned this pull request Jan 16, 2020
@EvanBoyle
Copy link
Contributor

EvanBoyle commented Jan 17, 2020

Thanks @csssuf for the contribution! After #3758 we're ready to merge this. I'm going to open a separate PR that updates the changelog.

@EvanBoyle EvanBoyle merged commit bf84a34 into pulumi:master Jan 17, 2020
@EvanBoyle
Copy link
Contributor

cc @bincyber I'm in the progress of getting this added to all of our providers, but you should be able to test this out in the meantime.

EvanBoyle added a commit that referenced this pull request Jan 17, 2020
EvanBoyle added a commit that referenced this pull request Jan 17, 2020
@csssuf csssuf deleted the pep-561 branch January 18, 2020 03:22
@csssuf
Copy link
Contributor Author

csssuf commented Jan 18, 2020

Thanks for all the work on getting the type hints in good shape! Very excited to start taking advantage of them.

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.

None yet

4 participants