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 let mypy get stub for type information #4412

Merged
merged 7 commits into from Aug 11, 2022

Conversation

jcwchen
Copy link
Member

@jcwchen jcwchen commented Aug 4, 2022

Description

  • Add py.typed to let mypy get stub for type information
  • Ship onnx/py.typed in the wheel to make type information available from PyPI.

Motivation and Context
Fixes #4404.

Signed-off-by: Chun-Wei Chen <jacky82226@gmail.com>
@jcwchen jcwchen added build Issues related to ONNX builds and packages run release CIs Use this label to trigger release tests in CI labels Aug 4, 2022
@jcwchen jcwchen requested a review from a team as a code owner August 4, 2022 22:33
Copy link
Member

@jbachurski jbachurski left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this proposed change both universally fixes the typing error on my setup & properly types proto objects and their fields (see my comment: #4404 (comment))

setup.py Outdated Show resolved Hide resolved
Co-authored-by: Jakub Bachurski <KubinGH@users.noreply.github.com>
Signed-off-by: Chun-Wei Chen <jacky82226@gmail.com>
Copy link
Member

@jbachurski jbachurski left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, issue seems to be fixed!

onnx/py.typed Outdated Show resolved Hide resolved
Signed-off-by: Chun-Wei Chen <jacky82226@gmail.com>
Signed-off-by: Chun-Wei Chen <jacky82226@gmail.com>
@@ -340,6 +340,7 @@ def run(self):
packages=packages,
license="Apache License v2.0",
include_package_data=True,
package_data={"onnx": ["py.typed", "*.pyi"]},
Copy link
Member Author

@jcwchen jcwchen Aug 10, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

One nit update: I removed adding py.typed in MANIFEST.in, because I think this line L343 will do the same thing here. I have tested that the updated ONNX wheel can still produce correct type information.

@jcwchen jcwchen enabled auto-merge (squash) August 11, 2022 14:16
@jcwchen jcwchen merged commit 7d64e7d into onnx:main Aug 11, 2022
broune pushed a commit to broune/onnx that referenced this pull request May 6, 2023
* Add py.typed to let mypy get stub for type information

Signed-off-by: Chun-Wei Chen <jacky82226@gmail.com>

* Update setup.py

Co-authored-by: Jakub Bachurski <KubinGH@users.noreply.github.com>
Signed-off-by: Chun-Wei Chen <jacky82226@gmail.com>

* add EOF

Signed-off-by: Chun-Wei Chen <jacky82226@gmail.com>

* remove py.typed in MANIFEST because package_data has included it

Signed-off-by: Chun-Wei Chen <jacky82226@gmail.com>

Signed-off-by: Chun-Wei Chen <jacky82226@gmail.com>
Co-authored-by: Jakub Bachurski <KubinGH@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
build Issues related to ONNX builds and packages run release CIs Use this label to trigger release tests in CI
Projects
Status: Done
Development

Successfully merging this pull request may close these issues.

No shipped stubs and using mypy
3 participants