From f3ad0179f83699a32a911fe07d3e45e3ac589e5e Mon Sep 17 00:00:00 2001 From: Alex Waygood Date: Mon, 14 Feb 2022 13:03:58 +0000 Subject: [PATCH] Fix return types in `codecs` (#7199) --- stdlib/codecs.pyi | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/stdlib/codecs.pyi b/stdlib/codecs.pyi index a9fa9c5d0..76efa38d5 100644 --- a/stdlib/codecs.pyi +++ b/stdlib/codecs.pyi @@ -217,12 +217,10 @@ class StreamReaderWriter(TextIO): def readlines(self, sizehint: int | None = ...) -> list[str]: ... def __next__(self) -> str: ... def __iter__(self: Self) -> Self: ... - # This actually returns None, but that's incompatible with the supertype - def write(self, data: str) -> int: ... + def write(self, data: str) -> None: ... # type: ignore[override] def writelines(self, list: Iterable[str]) -> None: ... def reset(self) -> None: ... - # Same as write() - def seek(self, offset: int, whence: int = ...) -> int: ... + def seek(self, offset: int, whence: int = ...) -> None: ... # type: ignore[override] def __enter__(self: Self) -> Self: ... def __exit__(self, typ: type[BaseException] | None, exc: BaseException | None, tb: types.TracebackType | None) -> None: ... def __getattr__(self, name: str) -> Any: ... @@ -253,15 +251,15 @@ class StreamRecoder(BinaryIO): def readlines(self, sizehint: int | None = ...) -> list[bytes]: ... def __next__(self) -> bytes: ... def __iter__(self: Self) -> Self: ... - def write(self, data: bytes) -> int: ... - def writelines(self, list: Iterable[bytes]) -> int: ... # type: ignore # it's supposed to return None + 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 __exit__(self, type: type[BaseException] | None, value: BaseException | None, tb: types.TracebackType | None) -> None: ... + def seek(self, offset: int, whence: int = ...) -> None: ... # type: ignore[override] # These methods don't actually exist directly, but they are needed to satisfy the BinaryIO # interface. At runtime, they are delegated through __getattr__. - def seek(self, offset: int, whence: int = ...) -> int: ... def close(self) -> None: ... def fileno(self) -> int: ... def flush(self) -> None: ...