Skip to content

Commit 009bc2d

Browse files
Update AsyncFileWrapper for consistency between what we need/what we declare (#3542)
* Update AsyncFileWrapper for consistency between what we need/what we declare * Add a newsfragment * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --------- Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
1 parent c631a83 commit 009bc2d

2 files changed

Lines changed: 5 additions & 4 deletions

File tree

‎newsfragments/3542.misc.rst‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
The typing for :ref:`async-file-objects` is now consistent about what it exposes based on what is exposed by the underlying object.

‎src/trio/_file_io.py‎

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -188,7 +188,7 @@ class _CanReadLines(Protocol[AnyStr]):
188188
def readlines(self, hint: int = ..., /) -> list[AnyStr]: ...
189189

190190
class _CanSeek(Protocol):
191-
def seek(self, target: int, whence: int = 0, /) -> int: ...
191+
def seek(self, target: int, whence: int = ..., /) -> int: ...
192192

193193
class _CanTell(Protocol):
194194
def tell(self) -> int: ...
@@ -204,7 +204,7 @@ class _CanWriteLines(Protocol[T_contra]):
204204
def writelines(self, lines: Iterable[T_contra], /) -> None: ...
205205

206206
class _CanPeek(Protocol[AnyStr_co]):
207-
def peek(self, size: int = 0, /) -> AnyStr_co: ...
207+
def peek(self, size: int = ..., /) -> AnyStr_co: ...
208208

209209
class _CanDetach(Protocol[T_co]):
210210
# The T typevar will be the unbuffered/binary file this file wraps.
@@ -313,7 +313,7 @@ def buffer(self: AsyncIOWrapper[_HasBuffer]) -> BinaryIO: ...
313313
@property
314314
def raw(self: AsyncIOWrapper[_HasRaw]) -> io.RawIOBase: ...
315315
@property
316-
def line_buffering(self: AsyncIOWrapper[_HasLineBuffering]) -> int: ...
316+
def line_buffering(self: AsyncIOWrapper[_HasLineBuffering]) -> bool: ...
317317
@property
318318
def closefd(self: AsyncIOWrapper[_HasCloseFD]) -> bool: ...
319319
@property
@@ -334,7 +334,7 @@ async def read1(self: AsyncIOWrapper[_CanRead1], size: int | None = -1, /) -> by
334334
async def readall(self: AsyncIOWrapper[_CanReadAll[AnyStr]]) -> AnyStr: ...
335335
async def readinto(self: AsyncIOWrapper[_CanReadInto], buf: Buffer, /) -> int | None: ...
336336
async def readline(self: AsyncIOWrapper[_CanReadLine[AnyStr]], size: int = -1, /) -> AnyStr: ...
337-
async def readlines(self: AsyncIOWrapper[_CanReadLines[AnyStr]]) -> list[AnyStr]: ...
337+
async def readlines(self: AsyncIOWrapper[_CanReadLines[AnyStr]], hint: int = -1, /) -> list[AnyStr]: ...
338338
async def seek(self: AsyncIOWrapper[_CanSeek], target: int, whence: int = 0, /) -> int: ...
339339
async def tell(self: AsyncIOWrapper[_CanTell]) -> int: ...
340340
async def truncate(self: AsyncIOWrapper[_CanTruncate], size: int | None = None, /) -> int: ...

0 commit comments

Comments
 (0)