Run black and isort w/ the new config

This commit is contained in:
Alex Stokes
2019-08-13 14:36:42 -07:00
parent 87375e0f23
commit 3debd2c808
37 changed files with 273 additions and 88 deletions

View File

@ -22,7 +22,10 @@ class IMuxedConn(ABC):
@abstractmethod
def __init__(
self, conn: ISecureConn, generic_protocol_handler: "GenericProtocolHandlerFn", peer_id: ID
self,
conn: ISecureConn,
generic_protocol_handler: "GenericProtocolHandlerFn",
peer_id: ID,
) -> None:
"""
create a new muxed connection
@ -54,7 +57,9 @@ class IMuxedConn(ABC):
"""
@abstractmethod
async def open_stream(self, protocol_id: str, multi_addr: Multiaddr) -> "IMuxedStream":
async def open_stream(
self, protocol_id: str, multi_addr: Multiaddr
) -> "IMuxedStream":
"""
creates a new muxed_stream
:param protocol_id: protocol_id of stream

View File

@ -90,7 +90,9 @@ class Mplex(IMuxedConn):
# Stream not created yet
return None
async def open_stream(self, protocol_id: str, multi_addr: Multiaddr) -> IMuxedStream:
async def open_stream(
self, protocol_id: str, multi_addr: Multiaddr
) -> IMuxedStream:
"""
creates a new muxed_stream
:param protocol_id: protocol_id of stream
@ -177,7 +179,9 @@ class Mplex(IMuxedConn):
try:
header = await decode_uvarint_from_stream(self.raw_conn.reader, timeout)
length = await decode_uvarint_from_stream(self.raw_conn.reader, timeout)
message = await asyncio.wait_for(self.raw_conn.reader.read(length), timeout=timeout)
message = await asyncio.wait_for(
self.raw_conn.reader.read(length), timeout=timeout
)
except asyncio.TimeoutError:
return None, None, None

View File

@ -47,7 +47,11 @@ class MplexStream(IMuxedStream):
write to stream
:return: number of bytes written
"""
flag = HeaderTags.MessageInitiator if self.initiator else HeaderTags.MessageReceiver
flag = (
HeaderTags.MessageInitiator
if self.initiator
else HeaderTags.MessageReceiver
)
return await self.mplex_conn.send_message(flag, data, self.stream_id)
async def close(self) -> bool:
@ -89,7 +93,11 @@ class MplexStream(IMuxedStream):
return True
if not self.remote_closed:
flag = HeaderTags.ResetInitiator if self.initiator else HeaderTags.ResetInitiator
flag = (
HeaderTags.ResetInitiator
if self.initiator
else HeaderTags.ResetInitiator
)
await self.mplex_conn.send_message(flag, None, self.stream_id)
self.local_closed = True

View File

@ -31,7 +31,9 @@ def decode_uvarint(buff: bytes, index: int) -> Tuple[int, int]:
return result, index + 1
async def decode_uvarint_from_stream(reader: asyncio.StreamReader, timeout: float) -> int:
async def decode_uvarint_from_stream(
reader: asyncio.StreamReader, timeout: float
) -> int:
shift = 0
result = 0
while True: