diff --git a/newsfragments/3542.misc.rst b/newsfragments/3542.misc.rst new file mode 100644 index 000000000..27d29ea97 --- /dev/null +++ b/newsfragments/3542.misc.rst @@ -0,0 +1 @@ +The typing for :ref:`async-file-objects` is now consistent about what it exposes based on what is exposed by the underlying object. diff --git a/src/trio/_file_io.py b/src/trio/_file_io.py index d9305ef4f..354d04838 100644 --- a/src/trio/_file_io.py +++ b/src/trio/_file_io.py @@ -188,7 +188,7 @@ class _CanReadLines(Protocol[AnyStr]): def readlines(self, hint: int = ..., /) -> list[AnyStr]: ... class _CanSeek(Protocol): - def seek(self, target: int, whence: int = 0, /) -> int: ... + def seek(self, target: int, whence: int = ..., /) -> int: ... class _CanTell(Protocol): def tell(self) -> int: ... @@ -204,7 +204,7 @@ class _CanWriteLines(Protocol[T_contra]): def writelines(self, lines: Iterable[T_contra], /) -> None: ... class _CanPeek(Protocol[AnyStr_co]): - def peek(self, size: int = 0, /) -> AnyStr_co: ... + def peek(self, size: int = ..., /) -> AnyStr_co: ... class _CanDetach(Protocol[T_co]): # The T typevar will be the unbuffered/binary file this file wraps. @@ -313,7 +313,7 @@ def buffer(self: AsyncIOWrapper[_HasBuffer]) -> BinaryIO: ... @property def raw(self: AsyncIOWrapper[_HasRaw]) -> io.RawIOBase: ... @property - def line_buffering(self: AsyncIOWrapper[_HasLineBuffering]) -> int: ... + def line_buffering(self: AsyncIOWrapper[_HasLineBuffering]) -> bool: ... @property def closefd(self: AsyncIOWrapper[_HasCloseFD]) -> bool: ... @property @@ -334,7 +334,7 @@ async def read1(self: AsyncIOWrapper[_CanRead1], size: int | None = -1, /) -> by async def readall(self: AsyncIOWrapper[_CanReadAll[AnyStr]]) -> AnyStr: ... async def readinto(self: AsyncIOWrapper[_CanReadInto], buf: Buffer, /) -> int | None: ... async def readline(self: AsyncIOWrapper[_CanReadLine[AnyStr]], size: int = -1, /) -> AnyStr: ... - async def readlines(self: AsyncIOWrapper[_CanReadLines[AnyStr]]) -> list[AnyStr]: ... + async def readlines(self: AsyncIOWrapper[_CanReadLines[AnyStr]], hint: int = -1, /) -> list[AnyStr]: ... async def seek(self: AsyncIOWrapper[_CanSeek], target: int, whence: int = 0, /) -> int: ... async def tell(self: AsyncIOWrapper[_CanTell]) -> int: ... async def truncate(self: AsyncIOWrapper[_CanTruncate], size: int | None = None, /) -> int: ...