From 9a4e23a803f245997cc00fb6c3193a2e7503cf0c Mon Sep 17 00:00:00 2001 From: Alex Stokes Date: Thu, 15 Aug 2019 16:36:32 -0700 Subject: [PATCH] mypy protobuf plugin requires keyword-based initializers --- libp2p/crypto/keys.py | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/libp2p/crypto/keys.py b/libp2p/crypto/keys.py index 4a43b41f..b0dec3d9 100644 --- a/libp2p/crypto/keys.py +++ b/libp2p/crypto/keys.py @@ -46,11 +46,9 @@ class PublicKey(Key): ... def serialize_to_protobuf(self) -> protobuf.PublicKey: - _type = self.get_type() + key_type = self.get_type().value data = self.to_bytes() - protobuf_key = protobuf.PublicKey() - protobuf_key.key_type = _type.value - protobuf_key.data = data + protobuf_key = protobuf.PublicKey(key_type=key_type, data=data) return protobuf_key @@ -68,11 +66,9 @@ class PrivateKey(Key): ... def serialize_to_protobuf(self) -> protobuf.PrivateKey: - _type = self.get_type() + key_type = self.get_type().value data = self.to_bytes() - protobuf_key = protobuf.PrivateKey() - protobuf_key.key_type = _type.value - protobuf_key.data = data + protobuf_key = protobuf.PrivateKey(key_type=key_type, data=data) return protobuf_key