From a33a12453744a4504bd4df259d98e7d15f82261b Mon Sep 17 00:00:00 2001 From: Jelle Zijlstra Date: Mon, 11 Jun 2018 13:59:38 -0700 Subject: [PATCH] make BZ2File and LZMAFile instantiable (#2115) Part of #1476. --- stdlib/2and3/bz2.pyi | 5 +++-- stdlib/3.3/lzma.pyi | 4 ++-- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/stdlib/2and3/bz2.pyi b/stdlib/2and3/bz2.pyi index 12cb9cc10..2cb329ce9 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 = ..., diff --git a/stdlib/3.3/lzma.pyi b/stdlib/3.3/lzma.pyi index e858d031f..e0a698341 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: ...