Use typing_extensions.Self in the stdlib (#9694)

This commit is contained in:
Alex Waygood
2023-02-09 09:12:13 +00:00
committed by GitHub
parent 10086c06a1
commit 9ed39d8796
98 changed files with 627 additions and 654 deletions

View File

@@ -2,12 +2,12 @@ import abc
import builtins
import codecs
import sys
from _typeshed import FileDescriptorOrPath, ReadableBuffer, Self, WriteableBuffer
from _typeshed import FileDescriptorOrPath, ReadableBuffer, WriteableBuffer
from collections.abc import Callable, Iterable, Iterator
from os import _Opener
from types import TracebackType
from typing import IO, Any, BinaryIO, TextIO
from typing_extensions import Literal
from typing_extensions import Literal, Self
__all__ = [
"BlockingIOError",
@@ -51,7 +51,7 @@ class UnsupportedOperation(OSError, ValueError): ...
class IOBase(metaclass=abc.ABCMeta):
def __iter__(self) -> Iterator[bytes]: ...
def __next__(self) -> bytes: ...
def __enter__(self: Self) -> Self: ...
def __enter__(self) -> Self: ...
def __exit__(
self, exc_type: type[BaseException] | None, exc_val: BaseException | None, exc_tb: TracebackType | None
) -> None: ...
@@ -100,7 +100,7 @@ class FileIO(RawIOBase, BinaryIO):
def closefd(self) -> bool: ...
def write(self, __b: ReadableBuffer) -> int: ...
def read(self, __size: int = -1) -> bytes: ...
def __enter__(self: Self) -> Self: ...
def __enter__(self) -> Self: ...
class BytesIO(BufferedIOBase, BinaryIO):
def __init__(self, initial_bytes: ReadableBuffer = ...) -> None: ...
@@ -108,23 +108,23 @@ class BytesIO(BufferedIOBase, BinaryIO):
# to allow BytesIO sub-classes to add this field, as it is defined
# as a read-only property on IO[].
name: Any
def __enter__(self: Self) -> Self: ...
def __enter__(self) -> Self: ...
def getvalue(self) -> bytes: ...
def getbuffer(self) -> memoryview: ...
def read1(self, __size: int | None = -1) -> bytes: ...
class BufferedReader(BufferedIOBase, BinaryIO):
def __enter__(self: Self) -> Self: ...
def __enter__(self) -> Self: ...
def __init__(self, raw: RawIOBase, buffer_size: int = ...) -> None: ...
def peek(self, __size: int = 0) -> bytes: ...
class BufferedWriter(BufferedIOBase, BinaryIO):
def __enter__(self: Self) -> Self: ...
def __enter__(self) -> Self: ...
def __init__(self, raw: RawIOBase, buffer_size: int = ...) -> None: ...
def write(self, __buffer: ReadableBuffer) -> int: ...
class BufferedRandom(BufferedReader, BufferedWriter):
def __enter__(self: Self) -> Self: ...
def __enter__(self) -> Self: ...
def seek(self, __target: int, __whence: int = 0) -> int: ... # stubtest needs this
class BufferedRWPair(BufferedIOBase):
@@ -172,7 +172,7 @@ class TextIOWrapper(TextIOBase, TextIO):
write_through: bool | None = None,
) -> None: ...
# These are inherited from TextIOBase, but must exist in the stub to satisfy mypy.
def __enter__(self: Self) -> Self: ...
def __enter__(self) -> Self: ...
def __iter__(self) -> Iterator[str]: ... # type: ignore[override]
def __next__(self) -> str: ... # type: ignore[override]
def writelines(self, __lines: Iterable[str]) -> None: ... # type: ignore[override]