fix(proxy): compare the stream buffer without narrowing the operand

typing.cast is banned here, and binding the isinstance-narrowed operand
only moved the basedpyright error to another rule. Compare the retained
frames with the other operand directly; behaviour is unchanged.
This commit is contained in:
Aryan Deshmukh 2026-10-24 12:47:19 +05:30
parent 340061916e
commit 16367a5969

View file

@ -1,6 +1,6 @@
from collections import deque
from collections.abc import Iterator, Sequence
from typing import Final, cast, overload
from typing import Final, overload
_FRAME_SEPARATORS: Final = (b"\r\n\r\n", b"\n\n")
@ -108,9 +108,7 @@ class BoundedChunkBuffer(Sequence[bytes]):
return len(self._frames())
def __eq__(self, other: object) -> bool:
if not isinstance(other, Sequence):
return False
return list(self) == list(cast(Sequence[object], other)) # cast-ok: isinstance narrows to Sequence[Unknown]
return list(self) == other
def __bool__(self) -> bool:
return self.total_bytes > 0