diff --git a/construct-stubs/core.pyi b/construct-stubs/core.pyi index 83a7525..392c8fc 100644 --- a/construct-stubs/core.pyi +++ b/construct-stubs/core.pyi @@ -30,7 +30,7 @@ from construct.lib import ( # type hint. But for supporting pyright/pylance, the same type hint has to be used as the return type of __new__. # (see discussion here: https://github.com/python/typeshed/issues/4846). -StreamType = t.BinaryIO +StreamType = t.IO[bytes] FilenameType = t.Union[str, bytes, os.PathLike[str], os.PathLike[bytes]] PathType = str ContextKWType = t.Any @@ -75,18 +75,18 @@ class CancelParsing(ConstructError): ... # used internally # =============================================================================== def stream_read( - stream: t.BinaryIO, length: int, path: t.Optional[PathType] + stream: StreamType, length: int, path: t.Optional[PathType] ) -> bytes: ... -def stream_read_entire(stream: t.BinaryIO, path: t.Optional[PathType]) -> bytes: ... +def stream_read_entire(stream: StreamType, path: t.Optional[PathType]) -> bytes: ... def stream_write( - stream: t.BinaryIO, data: bytes, length: int, path: t.Optional[PathType] + stream: StreamType, data: bytes, length: int, path: t.Optional[PathType] ) -> None: ... def stream_seek( - stream: t.BinaryIO, offset: int, whence: int, path: t.Optional[PathType] + stream: StreamType, offset: int, whence: int, path: t.Optional[PathType] ) -> int: ... -def stream_tell(stream: t.BinaryIO, path: t.Optional[PathType]) -> int: ... -def stream_size(stream: t.BinaryIO) -> int: ... -def stream_iseof(stream: t.BinaryIO) -> bool: ... +def stream_tell(stream: StreamType, path: t.Optional[PathType]) -> int: ... +def stream_size(stream: StreamType) -> int: ... +def stream_iseof(stream: StreamType) -> bool: ... def evaluate(param: ConstantOrContextLambda2[T], context: Context) -> T: ... # ===============================================================================