Fix type hints except pb msg in pubsub folder

This commit is contained in:
NIC619
2019-07-27 11:27:47 +08:00
parent a0aa105867
commit b2f496d081
6 changed files with 79 additions and 73 deletions

View File

@ -25,8 +25,9 @@ class IPubsubRouter(ABC):
:param pubsub: pubsub instance to attach to
"""
# FIXME: Should be changed to type 'peer.ID'
@abstractmethod
def add_peer(self, peer_id: ID, protocol_id: str) -> None:
def add_peer(self, peer_id: str, protocol_id: str) -> None:
"""
Notifies the router that a new peer has been connected
:param peer_id: id of peer to add
@ -39,8 +40,9 @@ class IPubsubRouter(ABC):
:param peer_id: id of peer to remove
"""
# FIXME: Should be changed to type 'peer.ID'
@abstractmethod
def handle_rpc(self, rpc: rpc_pb2.ControlMessage, sender_peer_id: ID) -> None:
async def handle_rpc(self, rpc: rpc_pb2.ControlMessage, sender_peer_id: str) -> None:
"""
Invoked to process control messages in the RPC envelope.
It is invoked after subscriptions and payload messages have been processed
@ -50,8 +52,9 @@ class IPubsubRouter(ABC):
:param rpc: rpc message
"""
# FIXME: Should be changed to type 'peer.ID'
@abstractmethod
async def publish(self, msg_forwarder: ID, pubsub_msg: rpc_pb2.Message):
async def publish(self, msg_forwarder: ID, pubsub_msg: rpc_pb2.Message) -> None:
"""
Invoked to forward a new message that has been validated
:param msg_forwarder: peer_id of message sender
@ -59,7 +62,7 @@ class IPubsubRouter(ABC):
"""
@abstractmethod
def join(self, topic: str) -> None:
async def join(self, topic: str) -> None:
"""
Join notifies the router that we want to receive and
forward messages in a topic. It is invoked after the
@ -68,7 +71,7 @@ class IPubsubRouter(ABC):
"""
@abstractmethod
def leave(self, topic: str) -> None:
async def leave(self, topic: str) -> None:
"""
Leave notifies the router that we are no longer interested in a topic.
It is invoked after the unsubscription announcement.