Skip to content

Commit 73b4c21

Browse files
Make ZipFile.__enter__ return self (#5675)
1 parent 3ec0610 commit 73b4c21

File tree

1 file changed

+18
-2
lines changed

1 file changed

+18
-2
lines changed

stdlib/zipfile.pyi

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,25 @@ import io
22
import sys
33
from _typeshed import StrPath
44
from types import TracebackType
5-
from typing import IO, Callable, Dict, Iterable, Iterator, List, Optional, Protocol, Sequence, Tuple, Type, Union, overload
5+
from typing import (
6+
IO,
7+
Callable,
8+
Dict,
9+
Iterable,
10+
Iterator,
11+
List,
12+
Optional,
13+
Protocol,
14+
Sequence,
15+
Tuple,
16+
Type,
17+
TypeVar,
18+
Union,
19+
overload,
20+
)
621
from typing_extensions import Literal
722

23+
_T = TypeVar("_T")
824
_DateTuple = Tuple[int, int, int, int, int, int]
925

1026
class BadZipFile(Exception): ...
@@ -128,7 +144,7 @@ class ZipFile:
128144
def __init__(
129145
self, file: Union[StrPath, IO[bytes]], mode: str = ..., compression: int = ..., allowZip64: bool = ...
130146
) -> None: ...
131-
def __enter__(self) -> ZipFile: ...
147+
def __enter__(self: _T) -> _T: ...
132148
def __exit__(
133149
self, exc_type: Optional[Type[BaseException]], exc_val: Optional[BaseException], exc_tb: Optional[TracebackType]
134150
) -> None: ...

0 commit comments

Comments
 (0)