Work around false mypy error about SubStream.__enter__

This commit is contained in:
dgelessus 2020-07-23 13:21:34 +02:00
parent 0054d0f7b5
commit 98551263b3
1 changed files with 6 additions and 0 deletions

View File

@ -49,6 +49,12 @@ class SubStream(io.BufferedIOBase, typing.BinaryIO):
if self._start_offset + self._length > outer_stream_length:
raise ValueError(f"start_offset ({self._start_offset}) or length ({self._length}) too high: outer stream must be at least {self._start_offset + self._length} bytes long, but is only {outer_stream_length} bytes")
# This override does nothing,
# but is needed to make mypy happy,
# otherwise it complains (apparently incorrectly) about the __enter__ definitions from IOBase and BinaryIO being incompatible with each other.
def __enter__(self: "SubStream") -> "SubStream":
return super().__enter__()
def seekable(self) -> bool:
return True