Add mypy protobufs plugin and regenerate protobufs

This commit is contained in:
Alex Stokes 2019-08-15 16:01:44 -07:00
parent 125c5d8e2c
commit 0f81ca42a6
No known key found for this signature in database
GPG Key ID: 51CE1721B245C086
4 changed files with 131 additions and 46 deletions

View File

@ -11,5 +11,5 @@ lintroll:
flake8 $(FILES_TO_LINT) flake8 $(FILES_TO_LINT)
protobufs: protobufs:
cd libp2p/crypto/pb && protoc --python_out=. crypto.proto cd libp2p/crypto/pb && protoc --python_out=. --mypy_out=. crypto.proto
cd libp2p/pubsub/pb && protoc --python_out=. rpc.proto cd libp2p/pubsub/pb && protoc --python_out=. --mypy_out=. rpc.proto

View File

@ -0,0 +1,84 @@
# @generated by generate_proto_mypy_stubs.py. Do not edit!
import sys
from google.protobuf.descriptor import (
Descriptor as google___protobuf___descriptor___Descriptor,
EnumDescriptor as google___protobuf___descriptor___EnumDescriptor,
)
from google.protobuf.message import (
Message as google___protobuf___message___Message,
)
from typing import (
List as typing___List,
Tuple as typing___Tuple,
cast as typing___cast,
)
from typing_extensions import (
Literal as typing_extensions___Literal,
)
class KeyType(int):
DESCRIPTOR: google___protobuf___descriptor___EnumDescriptor = ...
@classmethod
def Name(cls, number: int) -> str: ...
@classmethod
def Value(cls, name: str) -> KeyType: ...
@classmethod
def keys(cls) -> typing___List[str]: ...
@classmethod
def values(cls) -> typing___List[KeyType]: ...
@classmethod
def items(cls) -> typing___List[typing___Tuple[str, KeyType]]: ...
RSA = typing___cast(KeyType, 0)
Ed25519 = typing___cast(KeyType, 1)
Secp256k1 = typing___cast(KeyType, 2)
ECDSA = typing___cast(KeyType, 3)
RSA = typing___cast(KeyType, 0)
Ed25519 = typing___cast(KeyType, 1)
Secp256k1 = typing___cast(KeyType, 2)
ECDSA = typing___cast(KeyType, 3)
class PublicKey(google___protobuf___message___Message):
DESCRIPTOR: google___protobuf___descriptor___Descriptor = ...
key_type = ... # type: KeyType
data = ... # type: bytes
def __init__(self,
*,
key_type : KeyType,
data : bytes,
) -> None: ...
@classmethod
def FromString(cls, s: bytes) -> PublicKey: ...
def MergeFrom(self, other_msg: google___protobuf___message___Message) -> None: ...
def CopyFrom(self, other_msg: google___protobuf___message___Message) -> None: ...
if sys.version_info >= (3,):
def HasField(self, field_name: typing_extensions___Literal[u"data",u"key_type"]) -> bool: ...
def ClearField(self, field_name: typing_extensions___Literal[u"data",u"key_type"]) -> None: ...
else:
def HasField(self, field_name: typing_extensions___Literal[u"data",b"data",u"key_type",b"key_type"]) -> bool: ...
def ClearField(self, field_name: typing_extensions___Literal[u"data",b"data",u"key_type",b"key_type"]) -> None: ...
class PrivateKey(google___protobuf___message___Message):
DESCRIPTOR: google___protobuf___descriptor___Descriptor = ...
key_type = ... # type: KeyType
data = ... # type: bytes
def __init__(self,
*,
key_type : KeyType,
data : bytes,
) -> None: ...
@classmethod
def FromString(cls, s: bytes) -> PrivateKey: ...
def MergeFrom(self, other_msg: google___protobuf___message___Message) -> None: ...
def CopyFrom(self, other_msg: google___protobuf___message___Message) -> None: ...
if sys.version_info >= (3,):
def HasField(self, field_name: typing_extensions___Literal[u"data",u"key_type"]) -> bool: ...
def ClearField(self, field_name: typing_extensions___Literal[u"data",u"key_type"]) -> None: ...
else:
def HasField(self, field_name: typing_extensions___Literal[u"data",b"data",u"key_type",b"key_type"]) -> bool: ...
def ClearField(self, field_name: typing_extensions___Literal[u"data",b"data",u"key_type",b"key_type"]) -> None: ...

View File

@ -555,82 +555,82 @@ DESCRIPTOR.message_types_by_name['ControlPrune'] = _CONTROLPRUNE
DESCRIPTOR.message_types_by_name['TopicDescriptor'] = _TOPICDESCRIPTOR DESCRIPTOR.message_types_by_name['TopicDescriptor'] = _TOPICDESCRIPTOR
_sym_db.RegisterFileDescriptor(DESCRIPTOR) _sym_db.RegisterFileDescriptor(DESCRIPTOR)
RPC = _reflection.GeneratedProtocolMessageType('RPC', (_message.Message,), { RPC = _reflection.GeneratedProtocolMessageType('RPC', (_message.Message,), dict(
'SubOpts' : _reflection.GeneratedProtocolMessageType('SubOpts', (_message.Message,), { SubOpts = _reflection.GeneratedProtocolMessageType('SubOpts', (_message.Message,), dict(
'DESCRIPTOR' : _RPC_SUBOPTS, DESCRIPTOR = _RPC_SUBOPTS,
'__module__' : 'rpc_pb2' __module__ = 'rpc_pb2'
# @@protoc_insertion_point(class_scope:pubsub.pb.RPC.SubOpts) # @@protoc_insertion_point(class_scope:pubsub.pb.RPC.SubOpts)
}) ))
, ,
'DESCRIPTOR' : _RPC, DESCRIPTOR = _RPC,
'__module__' : 'rpc_pb2' __module__ = 'rpc_pb2'
# @@protoc_insertion_point(class_scope:pubsub.pb.RPC) # @@protoc_insertion_point(class_scope:pubsub.pb.RPC)
}) ))
_sym_db.RegisterMessage(RPC) _sym_db.RegisterMessage(RPC)
_sym_db.RegisterMessage(RPC.SubOpts) _sym_db.RegisterMessage(RPC.SubOpts)
Message = _reflection.GeneratedProtocolMessageType('Message', (_message.Message,), { Message = _reflection.GeneratedProtocolMessageType('Message', (_message.Message,), dict(
'DESCRIPTOR' : _MESSAGE, DESCRIPTOR = _MESSAGE,
'__module__' : 'rpc_pb2' __module__ = 'rpc_pb2'
# @@protoc_insertion_point(class_scope:pubsub.pb.Message) # @@protoc_insertion_point(class_scope:pubsub.pb.Message)
}) ))
_sym_db.RegisterMessage(Message) _sym_db.RegisterMessage(Message)
ControlMessage = _reflection.GeneratedProtocolMessageType('ControlMessage', (_message.Message,), { ControlMessage = _reflection.GeneratedProtocolMessageType('ControlMessage', (_message.Message,), dict(
'DESCRIPTOR' : _CONTROLMESSAGE, DESCRIPTOR = _CONTROLMESSAGE,
'__module__' : 'rpc_pb2' __module__ = 'rpc_pb2'
# @@protoc_insertion_point(class_scope:pubsub.pb.ControlMessage) # @@protoc_insertion_point(class_scope:pubsub.pb.ControlMessage)
}) ))
_sym_db.RegisterMessage(ControlMessage) _sym_db.RegisterMessage(ControlMessage)
ControlIHave = _reflection.GeneratedProtocolMessageType('ControlIHave', (_message.Message,), { ControlIHave = _reflection.GeneratedProtocolMessageType('ControlIHave', (_message.Message,), dict(
'DESCRIPTOR' : _CONTROLIHAVE, DESCRIPTOR = _CONTROLIHAVE,
'__module__' : 'rpc_pb2' __module__ = 'rpc_pb2'
# @@protoc_insertion_point(class_scope:pubsub.pb.ControlIHave) # @@protoc_insertion_point(class_scope:pubsub.pb.ControlIHave)
}) ))
_sym_db.RegisterMessage(ControlIHave) _sym_db.RegisterMessage(ControlIHave)
ControlIWant = _reflection.GeneratedProtocolMessageType('ControlIWant', (_message.Message,), { ControlIWant = _reflection.GeneratedProtocolMessageType('ControlIWant', (_message.Message,), dict(
'DESCRIPTOR' : _CONTROLIWANT, DESCRIPTOR = _CONTROLIWANT,
'__module__' : 'rpc_pb2' __module__ = 'rpc_pb2'
# @@protoc_insertion_point(class_scope:pubsub.pb.ControlIWant) # @@protoc_insertion_point(class_scope:pubsub.pb.ControlIWant)
}) ))
_sym_db.RegisterMessage(ControlIWant) _sym_db.RegisterMessage(ControlIWant)
ControlGraft = _reflection.GeneratedProtocolMessageType('ControlGraft', (_message.Message,), { ControlGraft = _reflection.GeneratedProtocolMessageType('ControlGraft', (_message.Message,), dict(
'DESCRIPTOR' : _CONTROLGRAFT, DESCRIPTOR = _CONTROLGRAFT,
'__module__' : 'rpc_pb2' __module__ = 'rpc_pb2'
# @@protoc_insertion_point(class_scope:pubsub.pb.ControlGraft) # @@protoc_insertion_point(class_scope:pubsub.pb.ControlGraft)
}) ))
_sym_db.RegisterMessage(ControlGraft) _sym_db.RegisterMessage(ControlGraft)
ControlPrune = _reflection.GeneratedProtocolMessageType('ControlPrune', (_message.Message,), { ControlPrune = _reflection.GeneratedProtocolMessageType('ControlPrune', (_message.Message,), dict(
'DESCRIPTOR' : _CONTROLPRUNE, DESCRIPTOR = _CONTROLPRUNE,
'__module__' : 'rpc_pb2' __module__ = 'rpc_pb2'
# @@protoc_insertion_point(class_scope:pubsub.pb.ControlPrune) # @@protoc_insertion_point(class_scope:pubsub.pb.ControlPrune)
}) ))
_sym_db.RegisterMessage(ControlPrune) _sym_db.RegisterMessage(ControlPrune)
TopicDescriptor = _reflection.GeneratedProtocolMessageType('TopicDescriptor', (_message.Message,), { TopicDescriptor = _reflection.GeneratedProtocolMessageType('TopicDescriptor', (_message.Message,), dict(
'AuthOpts' : _reflection.GeneratedProtocolMessageType('AuthOpts', (_message.Message,), { AuthOpts = _reflection.GeneratedProtocolMessageType('AuthOpts', (_message.Message,), dict(
'DESCRIPTOR' : _TOPICDESCRIPTOR_AUTHOPTS, DESCRIPTOR = _TOPICDESCRIPTOR_AUTHOPTS,
'__module__' : 'rpc_pb2' __module__ = 'rpc_pb2'
# @@protoc_insertion_point(class_scope:pubsub.pb.TopicDescriptor.AuthOpts) # @@protoc_insertion_point(class_scope:pubsub.pb.TopicDescriptor.AuthOpts)
}) ))
, ,
'EncOpts' : _reflection.GeneratedProtocolMessageType('EncOpts', (_message.Message,), { EncOpts = _reflection.GeneratedProtocolMessageType('EncOpts', (_message.Message,), dict(
'DESCRIPTOR' : _TOPICDESCRIPTOR_ENCOPTS, DESCRIPTOR = _TOPICDESCRIPTOR_ENCOPTS,
'__module__' : 'rpc_pb2' __module__ = 'rpc_pb2'
# @@protoc_insertion_point(class_scope:pubsub.pb.TopicDescriptor.EncOpts) # @@protoc_insertion_point(class_scope:pubsub.pb.TopicDescriptor.EncOpts)
}) ))
, ,
'DESCRIPTOR' : _TOPICDESCRIPTOR, DESCRIPTOR = _TOPICDESCRIPTOR,
'__module__' : 'rpc_pb2' __module__ = 'rpc_pb2'
# @@protoc_insertion_point(class_scope:pubsub.pb.TopicDescriptor) # @@protoc_insertion_point(class_scope:pubsub.pb.TopicDescriptor)
}) ))
_sym_db.RegisterMessage(TopicDescriptor) _sym_db.RegisterMessage(TopicDescriptor)
_sym_db.RegisterMessage(TopicDescriptor.AuthOpts) _sym_db.RegisterMessage(TopicDescriptor.AuthOpts)
_sym_db.RegisterMessage(TopicDescriptor.EncOpts) _sym_db.RegisterMessage(TopicDescriptor.EncOpts)

View File

@ -11,6 +11,7 @@ extras_require = {
], ],
"lint": [ "lint": [
"mypy>=0.701,<1.0", "mypy>=0.701,<1.0",
"mypy-protobuf==1.15",
"black==19.3b0", "black==19.3b0",
"isort==4.3.21", "isort==4.3.21",
"flake8>=3.7.7,<4.0.0", "flake8>=3.7.7,<4.0.0",