Add automatic docstring formatter and apply

This commit is contained in:
Dominik Muhs
2019-10-24 08:41:10 +02:00
parent 30aeb35122
commit eef505f2d9
74 changed files with 565 additions and 760 deletions

View File

@ -34,8 +34,8 @@ class MplexStream(IMuxedStream):
_buf: bytearray
def __init__(self, name: str, stream_id: StreamID, muxed_conn: "Mplex") -> None:
"""
create new MuxedStream in muxer
"""create new MuxedStream in muxer.
:param stream_id: stream id of this stream
:param muxed_conn: muxed connection of this muxed_stream
"""
@ -112,10 +112,10 @@ class MplexStream(IMuxedStream):
return bytes(payload)
async def read(self, n: int = -1) -> bytes:
"""
Read up to n bytes. Read possibly returns fewer than `n` bytes,
if there are not enough bytes in the Mplex buffer.
If `n == -1`, read until EOF.
"""Read up to n bytes. Read possibly returns fewer than `n` bytes, if
there are not enough bytes in the Mplex buffer. If `n == -1`, read
until EOF.
:param n: number of bytes to read
:return: bytes actually read
"""
@ -141,8 +141,8 @@ class MplexStream(IMuxedStream):
return bytes(payload)
async def write(self, data: bytes) -> int:
"""
write to stream
"""write to stream.
:return: number of bytes written
"""
if self.event_local_closed.is_set():
@ -155,10 +155,8 @@ class MplexStream(IMuxedStream):
return await self.muxed_conn.send_message(flag, data, self.stream_id)
async def close(self) -> None:
"""
Closing a stream closes it for writing and closes the remote end for reading
but allows writing in the other direction.
"""
"""Closing a stream closes it for writing and closes the remote end for
reading but allows writing in the other direction."""
# TODO error handling with timeout
async with self.close_lock:
@ -182,10 +180,7 @@ class MplexStream(IMuxedStream):
del self.muxed_conn.streams[self.stream_id]
async def reset(self) -> None:
"""
closes both ends of the stream
tells this remote side to hang up
"""
"""closes both ends of the stream tells this remote side to hang up."""
async with self.close_lock:
# Both sides have been closed. No need to event_reset.
if self.event_remote_closed.is_set() and self.event_local_closed.is_set():
@ -217,8 +212,8 @@ class MplexStream(IMuxedStream):
# TODO deadline not in use
def set_deadline(self, ttl: int) -> bool:
"""
set deadline for muxed stream
"""set deadline for muxed stream.
:return: True if successful
"""
self.read_deadline = ttl
@ -226,16 +221,16 @@ class MplexStream(IMuxedStream):
return True
def set_read_deadline(self, ttl: int) -> bool:
"""
set read deadline for muxed stream
"""set read deadline for muxed stream.
:return: True if successful
"""
self.read_deadline = ttl
return True
def set_write_deadline(self, ttl: int) -> bool:
"""
set write deadline for muxed stream
"""set write deadline for muxed stream.
:return: True if successful
"""
self.write_deadline = ttl