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

@ -1,12 +1,12 @@
import asyncio
from typing import (
List,
Sequence,
)
from multiaddr import Multiaddr
from libp2p.network.connection.raw_connection import (
RawConnection,
from libp2p.stream_muxer.mplex.mplex import (
Mplex,
)
from libp2p.network.notifee_interface import (
INotifee,
@ -17,21 +17,20 @@ from libp2p.network.network_interface import (
from libp2p.network.stream.net_stream_interface import (
INetStream,
)
from libp2p.peer.id import (
ID,
)
class PubsubNotifee(INotifee):
# pylint: disable=too-many-instance-attributes, cell-var-from-loop
initiator_peers_queue: List[ID]
# FIXME: Should be changed to type 'peer.ID'
initiator_peers_queue: asyncio.Queue[str]
def __init__(self, initiator_peers_queue: Sequence[ID]) -> None:
def __init__(self, initiator_peers_queue: asyncio.Queue[str]) -> None:
"""
:param initiator_peers_queue: queue to add new peers to so that pubsub
can process new peers after we connect to them
"""
self.initiator_peers_queue = List(initiator_peers_queue)
self.initiator_peers_queue = initiator_peers_queue
async def opened_stream(self, network: INetwork, stream: INetStream) -> None:
pass
@ -39,7 +38,7 @@ class PubsubNotifee(INotifee):
async def closed_stream(self, network: INetwork, stream: INetStream) -> None:
pass
async def connected(self, network: INetwork, conn: RawConnection) -> None:
async def connected(self, network: INetwork, conn: Mplex) -> None:
"""
Add peer_id to initiator_peers_queue, so that this peer_id can be used to
create a stream and we only want to have one pubsub stream with each peer.
@ -52,7 +51,7 @@ class PubsubNotifee(INotifee):
if conn.initiator:
await self.initiator_peers_queue.put(conn.peer_id)
async def disconnected(self, network: INetwork, conn: RawConnection) -> None:
async def disconnected(self, network: INetwork, conn: Mplex) -> None:
pass
async def listen(self, network: INetwork, multiaddr: Multiaddr) -> None: