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

Auto-generate .pyi Protobuf/gRPC files #193

Open
da-tanabe opened this issue Apr 1, 2021 · 0 comments
Open

Auto-generate .pyi Protobuf/gRPC files #193

da-tanabe opened this issue Apr 1, 2021 · 0 comments

Comments

@da-tanabe
Copy link
Contributor

The files that are emitted from protoc's Python plug in are fairly incomprehensible to mypy, PyCharm, and pretty much any other tool that tries to get typing information. This is the main blocker to enabling mypy over the entire codebase and being able to address issues like #189 as part of the build.

.pyi files have been manually introduced as part of #192, but maintaining them going forward will be quite error prone. Still, the exercise was instructive because it at least highlights the requirements of such a tool:

  • Handle references to other Protobuf files properly via imports, particularly taking into account that the we slightly modify the default Python packaging behavior of protoc.
  • Handle gRPC AsyncIO service stubs, somewhat complicated by the fact that the stubs themselves change their behavior based on the passed-in channel.
  • Literal types for key functions (WhichOneof) where restricting the allowable strings makes sense.
  • Constructors that understand the semantics around oneof and produce the appropriate overloads.
  • Properly-typed repeated types, particularly support for [T].add() -> T, which is a Protobuf-specific function.
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

No branches or pull requests

1 participant