Trying to read ext4 snapshots stored in S3 with s3fs, Volume refuses to work with s3fs.core.S3File instances which extend fsspec.spec.AbstractBufferedFile which extend io.IOBase. Now maybe AbstractBufferedFile should extend io.BufferedIOBase instead, but the check in Volume is not very pythonic, it could be a simple type hint.
Furthermore, the way the stream is used does not seem to handle the cases when io.RawIOBase.read returns fewer bytes than expected. Should only io.BufferedIOBase instances be accepted?
In short: would it make sense to remove the type assertion in Volume.__init__ and replace it with a type hint stream: io.BufferedIOBase ?
Trying to read ext4 snapshots stored in S3 with s3fs,
Volumerefuses to work withs3fs.core.S3Fileinstances which extendfsspec.spec.AbstractBufferedFilewhich extendio.IOBase. Now maybeAbstractBufferedFileshould extendio.BufferedIOBaseinstead, but the check inVolumeis not very pythonic, it could be a simple type hint.Furthermore, the way the
streamis used does not seem to handle the cases whenio.RawIOBase.readreturns fewer bytes than expected. Should onlyio.BufferedIOBaseinstances be accepted?In short: would it make sense to remove the type assertion in
Volume.__init__and replace it with a type hintstream: io.BufferedIOBase?