Skip to content

Make ZipFile.__enter__ return self #5675

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Jun 22, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 18 additions & 2 deletions stdlib/zipfile.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,25 @@ import io
import sys
from _typeshed import StrPath
from types import TracebackType
from typing import IO, Callable, Dict, Iterable, Iterator, List, Optional, Protocol, Sequence, Tuple, Type, Union, overload
from typing import (
IO,
Callable,
Dict,
Iterable,
Iterator,
List,
Optional,
Protocol,
Sequence,
Tuple,
Type,
TypeVar,
Union,
overload,
)
from typing_extensions import Literal

_T = TypeVar("_T")
_DateTuple = Tuple[int, int, int, int, int, int]

class BadZipFile(Exception): ...
Expand Down Expand Up @@ -128,7 +144,7 @@ class ZipFile:
def __init__(
self, file: Union[StrPath, IO[bytes]], mode: str = ..., compression: int = ..., allowZip64: bool = ...
) -> None: ...
def __enter__(self) -> ZipFile: ...
def __enter__(self: _T) -> _T: ...
def __exit__(
self, exc_type: Optional[Type[BaseException]], exc_val: Optional[BaseException], exc_tb: Optional[TracebackType]
) -> None: ...
Expand Down