Skip to content

Commit 205eceb

Browse files
committed
remove type ignores about python/mypy#5027
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 python#4082.
1 parent 694fa80 commit 205eceb

File tree

2 files changed

+8
-4
lines changed

2 files changed

+8
-4
lines changed

stdlib/2and3/bz2.pyi

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import io
22
import sys
3-
from typing import Any, IO, Optional, Union
3+
from typing import Any, IO, Optional, Union, TypeVar
44

55
if sys.version_info >= (3, 6):
66
from os import PathLike
@@ -9,6 +9,7 @@ elif sys.version_info >= (3, 3):
99
_PathOrFile = Union[str, bytes, IO[Any]]
1010
else:
1111
_PathOrFile = str
12+
_T = TypeVar("_T")
1213

1314
def compress(data: bytes, compresslevel: int = ...) -> bytes: ...
1415
def decompress(data: bytes) -> bytes: ...
@@ -21,7 +22,8 @@ if sys.version_info >= (3, 3):
2122
errors: Optional[str] = ...,
2223
newline: Optional[str] = ...) -> IO[Any]: ...
2324

24-
class BZ2File(io.BufferedIOBase, IO[bytes]): # type: ignore # python/mypy#5027
25+
class BZ2File(io.BufferedIOBase, IO[bytes]):
26+
def __enter__(self: _T) -> _T: ...
2527
if sys.version_info >= (3, 9):
2628
def __init__(self,
2729
filename: _PathOrFile,

stdlib/3/lzma.pyi

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import io
22
import sys
3-
from typing import Any, IO, Mapping, Optional, Sequence, Union
3+
from typing import Any, IO, Mapping, Optional, Sequence, Union, TypeVar
44

55
if sys.version_info >= (3, 6):
66
from os import PathLike
@@ -9,6 +9,7 @@ else:
99
_PathOrFile = Union[str, bytes, IO[Any]]
1010

1111
_FilterChain = Sequence[Mapping[str, Any]]
12+
_T = TypeVar("_T")
1213

1314
FORMAT_AUTO: int
1415
FORMAT_XZ: int
@@ -66,7 +67,7 @@ class LZMACompressor(object):
6667
class LZMAError(Exception): ...
6768

6869

69-
class LZMAFile(io.BufferedIOBase, IO[bytes]): # type: ignore # python/mypy#5027
70+
class LZMAFile(io.BufferedIOBase, IO[bytes]):
7071
def __init__(self,
7172
filename: Optional[_PathOrFile] = ...,
7273
mode: str = ...,
@@ -75,6 +76,7 @@ class LZMAFile(io.BufferedIOBase, IO[bytes]): # type: ignore # python/mypy#502
7576
check: int = ...,
7677
preset: Optional[int] = ...,
7778
filters: Optional[_FilterChain] = ...) -> None: ...
79+
def __enter__(self: _T) -> _T: ...
7880
def close(self) -> None: ...
7981
@property
8082
def closed(self) -> bool: ...

0 commit comments

Comments
 (0)