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

@@ -1,11 +1,11 @@
import sys
import types
from _codecs import *
from _typeshed import ReadableBuffer, Self
from _typeshed import ReadableBuffer
from abc import abstractmethod
from collections.abc import Callable, Generator, Iterable
from typing import Any, BinaryIO, Protocol, TextIO
from typing_extensions import Literal
from typing_extensions import Literal, Self
__all__ = [
"register",
@@ -110,7 +110,7 @@ class CodecInfo(tuple[_Encoder, _Decoder, _StreamReader, _StreamWriter]):
def incrementaldecoder(self) -> _IncrementalDecoder: ...
name: str
def __new__(
cls: type[Self],
cls,
encode: _Encoder,
decode: _Decoder,
streamreader: _StreamReader | None = None,
@@ -210,7 +210,7 @@ class StreamWriter(Codec):
def write(self, object: str) -> None: ...
def writelines(self, list: Iterable[str]) -> None: ...
def reset(self) -> None: ...
def __enter__(self: Self) -> Self: ...
def __enter__(self) -> Self: ...
def __exit__(self, type: type[BaseException] | None, value: BaseException | None, tb: types.TracebackType | None) -> None: ...
def __getattr__(self, name: str, getattr: Callable[[str], Any] = ...) -> Any: ...
@@ -222,9 +222,9 @@ class StreamReader(Codec):
def readline(self, size: int | None = None, keepends: bool = True) -> str: ...
def readlines(self, sizehint: int | None = None, keepends: bool = True) -> list[str]: ...
def reset(self) -> None: ...
def __enter__(self: Self) -> Self: ...
def __enter__(self) -> Self: ...
def __exit__(self, type: type[BaseException] | None, value: BaseException | None, tb: types.TracebackType | None) -> None: ...
def __iter__(self: Self) -> Self: ...
def __iter__(self) -> Self: ...
def __next__(self) -> str: ...
def __getattr__(self, name: str, getattr: Callable[[str], Any] = ...) -> Any: ...
@@ -237,12 +237,12 @@ class StreamReaderWriter(TextIO):
def readline(self, size: int | None = None) -> str: ...
def readlines(self, sizehint: int | None = None) -> list[str]: ...
def __next__(self) -> str: ...
def __iter__(self: Self) -> Self: ...
def __iter__(self) -> Self: ...
def write(self, data: str) -> None: ... # type: ignore[override]
def writelines(self, list: Iterable[str]) -> None: ...
def reset(self) -> None: ...
def seek(self, offset: int, whence: int = 0) -> None: ... # type: ignore[override]
def __enter__(self: Self) -> Self: ...
def __enter__(self) -> Self: ...
def __exit__(self, type: type[BaseException] | None, value: BaseException | None, tb: types.TracebackType | None) -> None: ...
def __getattr__(self, name: str) -> Any: ...
# These methods don't actually exist directly, but they are needed to satisfy the TextIO
@@ -271,12 +271,12 @@ class StreamRecoder(BinaryIO):
def readline(self, size: int | None = None) -> bytes: ...
def readlines(self, sizehint: int | None = None) -> list[bytes]: ...
def __next__(self) -> bytes: ...
def __iter__(self: Self) -> Self: ...
def __iter__(self) -> Self: ...
def write(self, data: bytes) -> None: ... # type: ignore[override]
def writelines(self, list: Iterable[bytes]) -> None: ...
def reset(self) -> None: ...
def __getattr__(self, name: str) -> Any: ...
def __enter__(self: Self) -> Self: ...
def __enter__(self) -> Self: ...
def __exit__(self, type: type[BaseException] | None, value: BaseException | None, tb: types.TracebackType | None) -> None: ...
def seek(self, offset: int, whence: int = 0) -> None: ... # type: ignore[override]
# These methods don't actually exist directly, but they are needed to satisfy the BinaryIO