protoc 3.0.0 or greater python 2.7, 3.5, 3.6, 3.7 python-protobuf >= 3.7.1 mypy >= v0.701
Other configurations may work, but are not supported in testing currently. We would be open to expanding this list if a need arises - file an issue on the issue tracker.
There is a python implementation of the plugin in python/protoc-gen-mypy
. On windows
you will have to use python/protoc_gen_mypy.bat
for the executable.
The plugin can be installed with
pip install mypy-protobuf
On posix, ensure that the protoc-gen-mypy script installed onto your $PATH. Then run.
protoc --python_out=output/location --mypy_out=output/location
Alternately, you can explicitly provide the path:
protoc --plugin=protoc-gen-mypy=path/to/protoc-gen-mypy --python_out=output/location --mypy_out=output/location
On windows, provide the bat file:
protoc --plugin=protoc-gen-mypy=path/to/protoc_gen_mypy.bat --python_out=output/location --mypy_out=output/location
To suppress output, you can run
protoc --python_out=output/location --mypy_out=quiet:output/location
There is a go implementation of the plugin in go/src/protoc-gen-mypy
.
The import sort order can be customized to split between stdlib and project protos
by changing the project
const at the top of the file (we use dropbox since our
proto files are namespaced under dropbox/)
To build the plugin:
- Configure GOPATH to point to the
go
directory of this repo. - Configure GOROOT (if your go compiler is before 1.8)
git clone https://github.com/gogo/protobuf.git go/src/github.com/gogo/protobuf
go build go/src/protoc-gen-mypy/main.go
The plugin can be used by adding the built target to the command line
when running protoc
(in addition to the normal plugin for output languages).
Dropbox internally uses both implementations. We internally directly use the python implementation. However, the go implementation here is a code drop from the Dropbox internal implementation with periodic re-upstreams. As a result, the python implementation will get more timely support. We encourage community contribution to improve quality/testing to bring both implementations to parity.
- @Ketouem
- @nmiculinic
- @onto
- @jcppkkk
- @drather19
- @smessmer
- @pcorpet
- @zozoens31
- @abhishekrb19
- @jaens
- @arussellsaw
- @shabbyrobe
- @reorx
- License: Apache 2.0.
- Copyright attribution: Copyright (c) 2017 Dropbox, Inc.
- External contributions to the project should be subject to Dropbox's Contributor License Agreement (CLA): https://opensource.dropbox.com/cla/