diff --git a/stdlib/aifc.pyi b/stdlib/aifc.pyi index b43af47ff5e8..25df252fe30e 100644 --- a/stdlib/aifc.pyi +++ b/stdlib/aifc.pyi @@ -1,4 +1,5 @@ import sys +from _typeshed import Self from types import TracebackType from typing import IO, Any, List, NamedTuple, Optional, Tuple, Type, Union, overload from typing_extensions import Literal @@ -18,7 +19,7 @@ _Marker = Tuple[int, int, bytes] class Aifc_read: def __init__(self, f: _File) -> None: ... - def __enter__(self) -> Aifc_read: ... + def __enter__(self: Self) -> Self: ... def __exit__( self, exc_type: Optional[Type[BaseException]], exc_val: Optional[BaseException], exc_tb: Optional[TracebackType] ) -> None: ... @@ -42,7 +43,7 @@ class Aifc_read: class Aifc_write: def __init__(self, f: _File) -> None: ... def __del__(self) -> None: ... - def __enter__(self) -> Aifc_write: ... + def __enter__(self: Self) -> Self: ... def __exit__( self, exc_type: Optional[Type[BaseException]], exc_val: Optional[BaseException], exc_tb: Optional[TracebackType] ) -> None: ... diff --git a/stdlib/asyncio/windows_utils.pyi b/stdlib/asyncio/windows_utils.pyi index e6009d58ebc7..1d16127a5ebe 100644 --- a/stdlib/asyncio/windows_utils.pyi +++ b/stdlib/asyncio/windows_utils.pyi @@ -1,4 +1,5 @@ import sys +from _typeshed import Self from types import TracebackType from typing import Callable, Optional, Protocol, Tuple, Type @@ -18,7 +19,7 @@ class PipeHandle: def __del__(self, _warn: _WarnFunction = ...) -> None: ... else: def __del__(self) -> None: ... - def __enter__(self) -> PipeHandle: ... + def __enter__(self: Self) -> Self: ... def __exit__(self, t: Optional[type], v: Optional[BaseException], tb: Optional[TracebackType]) -> None: ... @property def handle(self) -> int: ... diff --git a/stdlib/imaplib.pyi b/stdlib/imaplib.pyi index 9fc3a740c463..8ad242cca0f7 100644 --- a/stdlib/imaplib.pyi +++ b/stdlib/imaplib.pyi @@ -1,6 +1,7 @@ import subprocess import sys import time +from _typeshed import Self from socket import socket as _socket from ssl import SSLContext, SSLSocket from types import TracebackType @@ -59,7 +60,7 @@ class IMAP4: def delete(self, mailbox: str) -> _CommandResults: ... def deleteacl(self, mailbox: str, who: str) -> _CommandResults: ... def enable(self, capability: str) -> _CommandResults: ... - def __enter__(self) -> IMAP4: ... + def __enter__(self: Self) -> Self: ... def __exit__(self, t: Optional[Type[BaseException]], v: Optional[BaseException], tb: Optional[TracebackType]) -> None: ... def expunge(self) -> _CommandResults: ... def fetch(self, message_set: str, message_parts: str) -> Tuple[str, _AnyResponseData]: ... diff --git a/stdlib/multiprocessing/connection.pyi b/stdlib/multiprocessing/connection.pyi index 15f58a3745f3..c87dd310e37f 100644 --- a/stdlib/multiprocessing/connection.pyi +++ b/stdlib/multiprocessing/connection.pyi @@ -1,6 +1,7 @@ import socket import sys import types +from _typeshed import Self from typing import Any, Iterable, List, Optional, Tuple, Type, Union if sys.version_info >= (3, 8): @@ -48,7 +49,7 @@ class Listener: def address(self) -> _Address: ... @property def last_accepted(self) -> Optional[_Address]: ... - def __enter__(self) -> Listener: ... + def __enter__(self: Self) -> Self: ... def __exit__( self, exc_type: Optional[Type[BaseException]], exc_value: Optional[BaseException], exc_tb: Optional[types.TracebackType] ) -> None: ... diff --git a/stdlib/shelve.pyi b/stdlib/shelve.pyi index ed062f62b49b..2e36338dba70 100644 --- a/stdlib/shelve.pyi +++ b/stdlib/shelve.pyi @@ -1,4 +1,5 @@ import collections.abc +from _typeshed import Self from typing import Any, Dict, Iterator, Optional, Tuple class Shelf(collections.abc.MutableMapping[Any, Any]): @@ -12,7 +13,7 @@ class Shelf(collections.abc.MutableMapping[Any, Any]): def __getitem__(self, key: str) -> Any: ... def __setitem__(self, key: str, value: Any) -> None: ... def __delitem__(self, key: str) -> None: ... - def __enter__(self) -> Shelf: ... + def __enter__(self: Self) -> Self: ... def __exit__(self, type: Any, value: Any, traceback: Any) -> None: ... def close(self) -> None: ... def __del__(self) -> None: ... diff --git a/stdlib/smtplib.pyi b/stdlib/smtplib.pyi index 48a35f8e3b67..5d0ab420ee28 100644 --- a/stdlib/smtplib.pyi +++ b/stdlib/smtplib.pyi @@ -1,3 +1,4 @@ +from _typeshed import Self from email.message import Message as _Message from socket import socket from ssl import SSLContext @@ -75,7 +76,7 @@ class SMTP: timeout: float = ..., source_address: Optional[_SourceAddress] = ..., ) -> None: ... - def __enter__(self) -> SMTP: ... + def __enter__(self: Self) -> Self: ... def __exit__( self, exc_type: Optional[Type[BaseException]], exc_value: Optional[BaseException], tb: Optional[TracebackType] ) -> None: ... diff --git a/stdlib/wave.pyi b/stdlib/wave.pyi index 61f9136ea334..cafdcd408398 100644 --- a/stdlib/wave.pyi +++ b/stdlib/wave.pyi @@ -1,4 +1,5 @@ import sys +from _typeshed import Self from typing import IO, Any, BinaryIO, NamedTuple, NoReturn, Optional, Union _File = Union[str, IO[bytes]] @@ -17,7 +18,7 @@ class _wave_params(NamedTuple): class Wave_read: def __init__(self, f: _File) -> None: ... - def __enter__(self) -> Wave_read: ... + def __enter__(self: Self) -> Self: ... def __exit__(self, *args: Any) -> None: ... def getfp(self) -> Optional[BinaryIO]: ... def rewind(self) -> None: ... @@ -37,7 +38,7 @@ class Wave_read: class Wave_write: def __init__(self, f: _File) -> None: ... - def __enter__(self) -> Wave_write: ... + def __enter__(self: Self) -> Self: ... def __exit__(self, *args: Any) -> None: ... def setnchannels(self, nchannels: int) -> None: ... def getnchannels(self) -> int: ...