From 2d0a393ae0cbecd2431ef4eec3cd91bc32f5dde8 Mon Sep 17 00:00:00 2001 From: Sebastian Rittau Date: Tue, 6 Jun 2023 12:37:14 +0200 Subject: [PATCH] Tighten TextIOWrapper buffer types This matches the documentation, which says: > A buffered text stream providing higher-level access to a BufferedIOBase > buffered binary stream. Cf #10229 --- stdlib/io.pyi | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/stdlib/io.pyi b/stdlib/io.pyi index c114f839594f..0bccd5cd579d 100644 --- a/stdlib/io.pyi +++ b/stdlib/io.pyi @@ -147,7 +147,7 @@ class TextIOBase(IOBase): class TextIOWrapper(TextIOBase, TextIO): # type: ignore[misc] # incompatible definitions of write in the base classes def __init__( self, - buffer: IO[bytes], + buffer: BufferedIOBase, encoding: str | None = ..., errors: str | None = ..., newline: str | None = ..., @@ -155,7 +155,7 @@ class TextIOWrapper(TextIOBase, TextIO): # type: ignore[misc] # incompatible d write_through: bool = ..., ) -> None: ... @property - def buffer(self) -> BinaryIO: ... + def buffer(self) -> BufferedIOBase: ... # type: ignore[override] @property def closed(self) -> bool: ... @property @@ -178,6 +178,7 @@ class TextIOWrapper(TextIOBase, TextIO): # type: ignore[misc] # incompatible d def writelines(self, __lines: Iterable[str]) -> None: ... # type: ignore[override] def readline(self, __size: int = -1) -> str: ... # type: ignore[override] def readlines(self, __hint: int = -1) -> list[str]: ... # type: ignore[override] + def detach(self) -> BufferedIOBase: ... # type: ignore[override] def seek(self, __cookie: int, __whence: int = 0) -> int: ... # stubtest needs this class StringIO(TextIOWrapper):