Fix return annotations of several methods that return self at runtime (#7070)

This commit is contained in:
Alex Waygood
2022-01-29 01:37:49 +00:00
committed by GitHub
parent 749d3db815
commit 33ecb68603
8 changed files with 19 additions and 15 deletions

View File

@@ -86,7 +86,7 @@ class CodecInfo(tuple[_Encoder, _Decoder, _StreamReader, _StreamWriter]):
def incrementaldecoder(self) -> _IncrementalDecoder: ...
name: str
def __new__(
cls,
cls: type[Self],
encode: _Encoder,
decode: _Decoder,
streamreader: _StreamReader | None = ...,
@@ -96,7 +96,7 @@ class CodecInfo(tuple[_Encoder, _Decoder, _StreamReader, _StreamWriter]):
name: str | None = ...,
*,
_is_text_encoding: bool | None = ...,
) -> CodecInfo: ...
) -> Self: ...
def getencoder(encoding: str) -> _Encoder: ...
def getdecoder(encoding: str) -> _Decoder: ...
@@ -189,7 +189,7 @@ class StreamWriter(Codec):
def __exit__(self, typ: type[BaseException] | None, exc: BaseException | None, tb: types.TracebackType | None) -> None: ...
def __getattr__(self, name: str, getattr: Callable[[str], Any] = ...) -> Any: ...
class StreamReader(Codec):
class StreamReader(Codec, Iterator[str]):
errors: str
def __init__(self, stream: IO[bytes], errors: str = ...) -> None: ...
def read(self, size: int = ..., chars: int = ..., firstline: bool = ...) -> str: ...
@@ -198,7 +198,8 @@ class StreamReader(Codec):
def reset(self) -> None: ...
def __enter__(self: Self) -> Self: ...
def __exit__(self, typ: type[BaseException] | None, exc: BaseException | None, tb: types.TracebackType | None) -> None: ...
def __iter__(self) -> Iterator[str]: ...
def __iter__(self: Self) -> Self: ...
def __next__(self) -> str: ...
def __getattr__(self, name: str, getattr: Callable[[str], Any] = ...) -> Any: ...
# Doesn't actually inherit from TextIO, but wraps a BinaryIO to provide text reading and writing