Monday 5 February 2018

Dropbox releases mypy-protobuf

At Dropbox we use Google’s Protocol Buffers a lot. So much, in fact, that we sorely needed a way to generate mypy stub files (.pyi files) that match the generated .py files. And out of sheer enthusiasm we implemented the stub file generation code twice! Once in Go, once in Python. Go figure. :-)

We’ve now open-sourced both versions, so if you’re a Python shop, you can use the Python version, while if you’re a Go shop that occasionally uses Python, or you want a faster stub generator, you can use the Go version.

Ready to give it a try? Here’s the repo: https://github.com/dropbox/mypy-protobuf; instructions for both versions are in the top-level README.md. If you’re going for the Python version there’s no need to clone the repo: just pip install mypy-protobuf and pass --mypy_out=<somewhere> to your protoc invocation.