Skip to content

Commit c80622f

Browse files
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.
1 parent 846d922 commit c80622f

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,14 +1,15 @@
11
import io
22
import sys
33
from os.path import _PathType
4-
from typing import IO, Any, Optional, TextIO, Union, overload
4+
from typing import IO, Any, Optional, TextIO, Union, overload, TypeVar
55

66
if sys.version_info >= (3, 8):
77
from typing import Literal
88
else:
99
from typing_extensions import Literal
1010

1111
_PathOrFile = Union[_PathType, IO[bytes]]
12+
_T = TypeVar("_T")
1213

1314
def compress(data: bytes, compresslevel: int = ...) -> bytes: ...
1415
def decompress(data: bytes) -> bytes: ...
@@ -44,7 +45,8 @@ if sys.version_info >= (3, 3):
4445
newline: Optional[str] = ...,
4546
) -> Union[BZ2File, TextIO]: ...
4647

47-
class BZ2File(io.BufferedIOBase, IO[bytes]): # type: ignore # python/mypy#5027
48+
class BZ2File(io.BufferedIOBase, IO[bytes]):
49+
def __enter__(self: _T) -> _T: ...
4850
if sys.version_info >= (3, 9):
4951
def __init__(self,
5052
filename: _PathOrFile,

stdlib/3/lzma.pyi

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import io
22
import sys
33
from os.path import _PathType
4-
from typing import IO, Any, Mapping, Optional, Sequence, TextIO, Union, overload
4+
from typing import IO, Any, Mapping, Optional, Sequence, TextIO, TypeVar, Union, overload
55

66
if sys.version_info >= (3, 8):
77
from typing import Literal
@@ -14,6 +14,7 @@ _OpenTextWritingMode = Literal["wt", "xt", "at"]
1414
_PathOrFile = Union[_PathType, IO[bytes]]
1515

1616
_FilterChain = Sequence[Mapping[str, Any]]
17+
_T = TypeVar("_T")
1718

1819
FORMAT_AUTO: int
1920
FORMAT_XZ: int
@@ -69,7 +70,7 @@ class LZMACompressor(object):
6970

7071
class LZMAError(Exception): ...
7172

72-
class LZMAFile(io.BufferedIOBase, IO[bytes]): # type: ignore # python/mypy#5027
73+
class LZMAFile(io.BufferedIOBase, IO[bytes]):
7374
def __init__(
7475
self,
7576
filename: Optional[_PathOrFile] = ...,
@@ -80,6 +81,7 @@ class LZMAFile(io.BufferedIOBase, IO[bytes]): # type: ignore # python/mypy#502
8081
preset: Optional[int] = ...,
8182
filters: Optional[_FilterChain] = ...,
8283
) -> None: ...
84+
def __enter__(self: _T) -> _T: ...
8385
def close(self) -> None: ...
8486
@property
8587
def closed(self) -> bool: ...

0 commit comments

Comments
 (0)