Git Product home page Git Product logo

mypy-protobuf's Introduction

mypy-protobuf: Generate mypy stub files from protobuf specs Build Status

Requirements

protoc 3.0.0 or greater python 2.7 or 3.5 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.

Python Implementation

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

Go Implementation

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:

  1. Configure GOPATH to point to the go directory of this repo.
  2. Configure GOROOT (if your go compiler is before 1.8)
  3. git clone https://github.com/gogo/protobuf.git go/src/github.com/gogo/protobuf
  4. 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).

Support

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.

Contributors

Dropboxers

Others

Licence etc.

  1. License: Apache 2.0.
  2. Copyright attribution: Copyright (c) 2017 Dropbox, Inc.
  3. External contributions to the project should be subject to Dropbox's Contributor License Agreement (CLA): https://opensource.dropbox.com/cla/

mypy-protobuf's People

Contributors

nipunn1313 avatar smessmer avatar pcorpet avatar dzbarsky avatar drather19 avatar onto avatar bradenaw avatar ketouem avatar zozoens31 avatar gvanrossum avatar jcppkkk avatar msullivan avatar nmiculinic avatar peterlvilim avatar

Watchers

James Cloos avatar Abhishek Radhakrishnan avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.