add typing to protocol_muxer

This commit is contained in:
Chih Cheng Liang
2019-08-07 18:02:30 +08:00
committed by Kevin Mai-Husan Chia
parent 0d709364f8
commit 5903012e0e
13 changed files with 72 additions and 43 deletions

View File

@ -1,3 +1,5 @@
from libp2p.stream_muxer.abc import IMuxedStream
from .multiselect_communicator_interface import IMultiselectCommunicator
@ -8,7 +10,9 @@ class MultiselectCommunicator(IMultiselectCommunicator):
which is necessary for them to work
"""
def __init__(self, reader_writer):
reader_writer: IMuxedStream
def __init__(self, reader_writer: IMuxedStream) -> None:
"""
MultistreamCommunicator expects a reader_writer object that has
an async read and an async write function (this could be a stream,
@ -16,14 +20,14 @@ class MultiselectCommunicator(IMultiselectCommunicator):
"""
self.reader_writer = reader_writer
async def write(self, msg_str):
async def write(self, msg_str: str) -> None:
"""
Write message to reader_writer
:param msg_str: message to write
"""
await self.reader_writer.write(msg_str.encode())
async def read_stream_until_eof(self):
async def read_stream_until_eof(self) -> str:
"""
Reads message from reader_writer until EOF
"""