From e44a276ef5f4044407d44a23b3e716ee55f8c59d Mon Sep 17 00:00:00 2001 From: Jelle Zijlstra Date: Sun, 13 May 2018 13:30:28 -0400 Subject: [PATCH 1/2] make BZ2File instantiable Part of #1476. --- stdlib/2and3/bz2.pyi | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/stdlib/2and3/bz2.pyi b/stdlib/2and3/bz2.pyi index 12cb9cc10b9b..2cb329ce93c8 100644 --- a/stdlib/2and3/bz2.pyi +++ b/stdlib/2and3/bz2.pyi @@ -1,5 +1,6 @@ +import io import sys -from typing import Any, BinaryIO, IO, Optional, Union +from typing import Any, IO, Optional, Union if sys.version_info >= (3, 6): from os import PathLike @@ -20,7 +21,7 @@ if sys.version_info >= (3, 3): errors: Optional[str] = ..., newline: Optional[str] = ...) -> IO[Any]: ... -class BZ2File(BinaryIO): +class BZ2File(io.BufferedIOBase, IO[bytes]): # type: ignore # python/mypy#5027 def __init__(self, filename: _PathOrFile, mode: str = ..., From 76c8b0879f13c2165e37a3e635064535f732c52a Mon Sep 17 00:00:00 2001 From: Jelle Zijlstra Date: Tue, 15 May 2018 16:08:25 -0400 Subject: [PATCH 2/2] make lzma.LZMAFile instantiable --- stdlib/3.3/lzma.pyi | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/stdlib/3.3/lzma.pyi b/stdlib/3.3/lzma.pyi index e858d031f41f..e0a69834196f 100644 --- a/stdlib/3.3/lzma.pyi +++ b/stdlib/3.3/lzma.pyi @@ -67,7 +67,7 @@ class LZMACompressor(object): class LZMAError(Exception): ... -class LZMAFile(BinaryIO): +class LZMAFile(io.BufferedIOBase, IO[bytes]): # type: ignore # python/mypy#5027 def __init__(self, filename: Optional[_PathOrFile] = ..., mode: str = ..., @@ -84,7 +84,7 @@ class LZMAFile(BinaryIO): def readable(self) -> bool: ... def writable(self) -> bool: ... def peek(self, size: int = ...) -> bytes: ... - def read(self, size: int = ...) -> bytes: ... + def read(self, size: Optional[int] = ...) -> bytes: ... def read1(self, size: int = ...) -> bytes: ... def readline(self, size: int = ...) -> bytes: ... def write(self, data: bytes) -> int: ...