remove type ignores about python/mypy#5027 (#4119)

The mypy issue got fixed by the good people of mypy. I did have to add an
override for __enter__ similar to what we're doing in #4082.
This commit is contained in:
Jelle Zijlstra
2020-05-28 09:51:54 -07:00
committed by GitHub
parent 846d922df2
commit c80622fbb9
2 changed files with 8 additions and 4 deletions

View File

@@ -1,7 +1,7 @@
import io
import sys
from os.path import _PathType
from typing import IO, Any, Optional, TextIO, Union, overload
from typing import IO, Any, Optional, TextIO, Union, overload, TypeVar
if sys.version_info >= (3, 8):
from typing import Literal
@@ -9,6 +9,7 @@ else:
from typing_extensions import Literal
_PathOrFile = Union[_PathType, IO[bytes]]
_T = TypeVar("_T")
def compress(data: bytes, compresslevel: int = ...) -> bytes: ...
def decompress(data: bytes) -> bytes: ...
@@ -44,7 +45,8 @@ if sys.version_info >= (3, 3):
newline: Optional[str] = ...,
) -> Union[BZ2File, TextIO]: ...
class BZ2File(io.BufferedIOBase, IO[bytes]): # type: ignore # python/mypy#5027
class BZ2File(io.BufferedIOBase, IO[bytes]):
def __enter__(self: _T) -> _T: ...
if sys.version_info >= (3, 9):
def __init__(self,
filename: _PathOrFile,

View File

@@ -1,7 +1,7 @@
import io
import sys
from os.path import _PathType
from typing import IO, Any, Mapping, Optional, Sequence, TextIO, Union, overload
from typing import IO, Any, Mapping, Optional, Sequence, TextIO, TypeVar, Union, overload
if sys.version_info >= (3, 8):
from typing import Literal
@@ -14,6 +14,7 @@ _OpenTextWritingMode = Literal["wt", "xt", "at"]
_PathOrFile = Union[_PathType, IO[bytes]]
_FilterChain = Sequence[Mapping[str, Any]]
_T = TypeVar("_T")
FORMAT_AUTO: int
FORMAT_XZ: int
@@ -69,7 +70,7 @@ class LZMACompressor(object):
class LZMAError(Exception): ...
class LZMAFile(io.BufferedIOBase, IO[bytes]): # type: ignore # python/mypy#5027
class LZMAFile(io.BufferedIOBase, IO[bytes]):
def __init__(
self,
filename: Optional[_PathOrFile] = ...,
@@ -80,6 +81,7 @@ class LZMAFile(io.BufferedIOBase, IO[bytes]): # type: ignore # python/mypy#502
preset: Optional[int] = ...,
filters: Optional[_FilterChain] = ...,
) -> None: ...
def __enter__(self: _T) -> _T: ...
def close(self) -> None: ...
@property
def closed(self) -> bool: ...