From bb3935e7ebb9426f54f4bd4a6f0a243dbb7184ff Mon Sep 17 00:00:00 2001 From: Tim Riddermann Date: Tue, 9 May 2023 12:27:46 +0200 Subject: [PATCH 1/2] fixes #19 --- construct-stubs/core.pyi | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/construct-stubs/core.pyi b/construct-stubs/core.pyi index 83a7525..093199f 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 From 2200a0a8d0ee4f965b9462b6001bd1272de95670 Mon Sep 17 00:00:00 2001 From: Tim Riddermann Date: Tue, 9 May 2023 12:31:38 +0200 Subject: [PATCH 2/2] fixed mypy errors --- construct-stubs/core.pyi | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/construct-stubs/core.pyi b/construct-stubs/core.pyi index 093199f..392c8fc 100644 --- a/construct-stubs/core.pyi +++ b/construct-stubs/core.pyi @@ -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: ... # ===============================================================================