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

Protobuf stubs update using mypy-protobuf #4785

Merged
merged 3 commits into from
Nov 25, 2020

Conversation

nipunn1313
Copy link
Contributor

This uses mypy-protobuf to check in up to date stubs for google.protobuf proto
files. The PR is split into two commits, one which checks in a script for generating
these stubs, and second for the generated .pyi stubs.

The current stubs were manually added from a very-old version of mypy-protobuf years ago (before mypy-protobuf was even open source). This PR updates them, and streamlines the process for updating them again in the future. With each release of protobuf, typeshed will have to update the stubs.

Fixes nipunn1313/mypy-protobuf#158
Fixes #2521

Ultimately, much of this can be resolved by integrating mypy-protobuf with protobuf itself, but that's not currently on the horizon - tracked in both
nipunn1313/mypy-protobuf#95
protocolbuffers/protobuf#2638 (comment)

@nipunn1313 nipunn1313 force-pushed the protoc_update branch 5 times, most recently from f7c58cf to ae428a9 Compare November 23, 2020 04:05
@nipunn1313 nipunn1313 changed the title Protoc update Protobuf stubs update using mypy-protobuf Nov 23, 2020
@nipunn1313
Copy link
Contributor Author

Sorry about all the force pushes! Took me a while to figure out how to skip black/isort/pytype/flake8 on these autogenerated files. This should be ready now!

@@ -0,0 +1,62 @@
#!/bin/bash
Copy link
Member

Choose a reason for hiding this comment

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

Could you add a comment explaining the purpose of this file more directly?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

yep! I elaborate on the comment - describing that the script autogenerates the _pb2.pyi files

Copy link
Member

Choose a reason for hiding this comment

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

Thanks, sounds good!

Copy link
Member

@JelleZijlstra JelleZijlstra left a comment

Choose a reason for hiding this comment

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

This looks good to me but leaving it open for a little while in case @rchen152 wants to address the new pytype excludelist entries.

@rchen152
Copy link
Collaborator

Thanks for the ping! That's a lot of excludelist entries, so yeah, I think I'll want to fix the pytype parser. The Thanksgiving holiday is coming up, so I won't be able to release a fix until sometime next week at the earliest - feel free to merge this now, and I can clean up the pytype excludelist later.

@JelleZijlstra JelleZijlstra merged commit 9af49c0 into python:master Nov 25, 2020
@nipunn1313
Copy link
Contributor Author

Thanks friends!
@rchen152 - it was the same error for all the excluded files - so hopefully it's not too difficult to fix!

rchen152 added a commit to google/pytype that referenced this pull request Dec 8, 2020
This started as an attempt to support the stubs added to the pytype exclude list in python/typeshed#4785. Those stubs turned out to be a bit of a hairball, but supporting NewType seems useful anyway.

Resolves #597.

PiperOrigin-RevId: 345364292
@nipunn1313 nipunn1313 deleted the protoc_update branch July 10, 2021 23:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
3 participants