fix: linting error related to read

This commit is contained in:
Jinesh Jain
2025-07-08 19:11:56 +05:30
parent 8fb664bfdf
commit e65e38a3f1

View File

@ -140,6 +140,7 @@ class MplexStream(IMuxedStream):
:return: bytes actually read :return: bytes actually read
""" """
await self.rw_lock.acquire_read() await self.rw_lock.acquire_read()
payload: bytes = b""
try: try:
if n is not None and n < 0: if n is not None and n < 0:
raise ValueError( raise ValueError(
@ -180,12 +181,12 @@ class MplexStream(IMuxedStream):
"This should never happen." "This should never happen."
) from error ) from error
self._buf.extend(self._read_return_when_blocked()) self._buf.extend(self._read_return_when_blocked())
payload = self._buf[:n] chunk = self._buf[:n]
self._buf = self._buf[len(payload) :] self._buf = self._buf[len(chunk) :]
return bytes(payload) payload = bytes(chunk)
finally: finally:
await self.rw_lock.release_read() await self.rw_lock.release_read()
return b"" return payload
async def write(self, data: bytes) -> None: async def write(self, data: bytes) -> None:
""" """