Skip to content
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

Use _typeshed.Self where __enter__ returns self #5698

Merged
merged 2 commits into from
Jun 27, 2021
Merged
Show file tree
Hide file tree
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
5 changes: 3 additions & 2 deletions stdlib/aifc.pyi
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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: ...
Expand All @@ -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: ...
Expand Down
3 changes: 2 additions & 1 deletion stdlib/asyncio/windows_utils.pyi
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import sys
from _typeshed import Self
from types import TracebackType
from typing import Callable, Optional, Protocol, Tuple, Type

Expand All @@ -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: ...
Expand Down
3 changes: 2 additions & 1 deletion stdlib/imaplib.pyi
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -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]: ...
Expand Down
3 changes: 2 additions & 1 deletion stdlib/multiprocessing/connection.pyi
Original file line number Diff line number Diff line change
@@ -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):
Expand Down Expand Up @@ -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: ...
Expand Down
3 changes: 2 additions & 1 deletion stdlib/shelve.pyi
Original file line number Diff line number Diff line change
@@ -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]):
Expand All @@ -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: ...
Expand Down
3 changes: 2 additions & 1 deletion stdlib/smtplib.pyi
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
from _typeshed import Self
from email.message import Message as _Message
from socket import socket
from ssl import SSLContext
Expand Down Expand Up @@ -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: ...
Expand Down
5 changes: 3 additions & 2 deletions stdlib/wave.pyi
Original file line number Diff line number Diff line change
@@ -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]]
Expand All @@ -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: ...
Expand All @@ -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: ...
Expand Down