diff --git a/stubs/aiofiles/@tests/stubtest_allowlist.txt b/stubs/aiofiles/@tests/stubtest_allowlist.txt index 7640356fd..ae9f0d9a1 100644 --- a/stubs/aiofiles/@tests/stubtest_allowlist.txt +++ b/stubs/aiofiles/@tests/stubtest_allowlist.txt @@ -9,6 +9,15 @@ aiofiles.threadpool.binary.AsyncBufferedIOBase.readable aiofiles.threadpool.binary.AsyncBufferedIOBase.seekable aiofiles.threadpool.binary.AsyncBufferedIOBase.tell aiofiles.threadpool.binary.AsyncBufferedIOBase.writable +aiofiles.threadpool.binary.AsyncIndirectBufferedIOBase.close +aiofiles.threadpool.binary.AsyncIndirectBufferedIOBase.detach +aiofiles.threadpool.binary.AsyncIndirectBufferedIOBase.fileno +aiofiles.threadpool.binary.AsyncIndirectBufferedIOBase.flush +aiofiles.threadpool.binary.AsyncIndirectBufferedIOBase.isatty +aiofiles.threadpool.binary.AsyncIndirectBufferedIOBase.readable +aiofiles.threadpool.binary.AsyncIndirectBufferedIOBase.seekable +aiofiles.threadpool.binary.AsyncIndirectBufferedIOBase.tell +aiofiles.threadpool.binary.AsyncIndirectBufferedIOBase.writable aiofiles.threadpool.binary.AsyncFileIO.close aiofiles.threadpool.binary.AsyncFileIO.fileno aiofiles.threadpool.binary.AsyncFileIO.flush @@ -18,6 +27,15 @@ aiofiles.threadpool.binary.AsyncFileIO.readall aiofiles.threadpool.binary.AsyncFileIO.seekable aiofiles.threadpool.binary.AsyncFileIO.tell aiofiles.threadpool.binary.AsyncFileIO.writable +aiofiles.threadpool.binary.AsyncIndirectFileIO.close +aiofiles.threadpool.binary.AsyncIndirectFileIO.fileno +aiofiles.threadpool.binary.AsyncIndirectFileIO.flush +aiofiles.threadpool.binary.AsyncIndirectFileIO.isatty +aiofiles.threadpool.binary.AsyncIndirectFileIO.readable +aiofiles.threadpool.binary.AsyncIndirectFileIO.readall +aiofiles.threadpool.binary.AsyncIndirectFileIO.seekable +aiofiles.threadpool.binary.AsyncIndirectFileIO.tell +aiofiles.threadpool.binary.AsyncIndirectFileIO.writable aiofiles.threadpool.text.AsyncTextIOWrapper.close aiofiles.threadpool.text.AsyncTextIOWrapper.detach aiofiles.threadpool.text.AsyncTextIOWrapper.fileno @@ -27,6 +45,15 @@ aiofiles.threadpool.text.AsyncTextIOWrapper.readable aiofiles.threadpool.text.AsyncTextIOWrapper.seekable aiofiles.threadpool.text.AsyncTextIOWrapper.tell aiofiles.threadpool.text.AsyncTextIOWrapper.writable +aiofiles.threadpool.text.AsyncTextIndirectIOWrapper.close +aiofiles.threadpool.text.AsyncTextIndirectIOWrapper.detach +aiofiles.threadpool.text.AsyncTextIndirectIOWrapper.fileno +aiofiles.threadpool.text.AsyncTextIndirectIOWrapper.flush +aiofiles.threadpool.text.AsyncTextIndirectIOWrapper.isatty +aiofiles.threadpool.text.AsyncTextIndirectIOWrapper.readable +aiofiles.threadpool.text.AsyncTextIndirectIOWrapper.seekable +aiofiles.threadpool.text.AsyncTextIndirectIOWrapper.tell +aiofiles.threadpool.text.AsyncTextIndirectIOWrapper.writable # These functions get the wrong signature from functools.wraps() aiofiles.os.stat diff --git a/stubs/aiofiles/METADATA.toml b/stubs/aiofiles/METADATA.toml index f5ebbca06..156974ce2 100644 --- a/stubs/aiofiles/METADATA.toml +++ b/stubs/aiofiles/METADATA.toml @@ -1,4 +1,4 @@ -version = "22.1.*" +version = "23.1.*" [tool.stubtest] # linux and darwin are equivalent diff --git a/stubs/aiofiles/aiofiles/__init__.pyi b/stubs/aiofiles/aiofiles/__init__.pyi index 468393cba..bc52b8e0c 100644 --- a/stubs/aiofiles/aiofiles/__init__.pyi +++ b/stubs/aiofiles/aiofiles/__init__.pyi @@ -1,2 +1,10 @@ from . import tempfile as tempfile -from .threadpool import open as open +from .threadpool import ( + open as open, + stderr as stderr, + stderr_bytes as stderr_bytes, + stdin as stdin, + stdin_bytes as stdin_bytes, + stdout as stdout, + stdout_bytes as stdout_bytes, +) diff --git a/stubs/aiofiles/aiofiles/base.pyi b/stubs/aiofiles/aiofiles/base.pyi index cc9baf4a9..2cf93d4e7 100644 --- a/stubs/aiofiles/aiofiles/base.pyi +++ b/stubs/aiofiles/aiofiles/base.pyi @@ -1,6 +1,6 @@ -from collections.abc import Coroutine, Generator, Iterator +from collections.abc import Callable, Coroutine, Generator, Iterator from types import CodeType, FrameType, TracebackType, coroutine -from typing import Any, Generic, TypeVar +from typing import Any, BinaryIO, Generic, TextIO, TypeVar from typing_extensions import Self _T = TypeVar("_T") @@ -13,6 +13,9 @@ class AsyncBase(Generic[_T]): def __aiter__(self) -> Self: ... async def __anext__(self) -> _T: ... +class AsyncIndirectBase(AsyncBase[_T]): + def __init__(self, name: str, loop: Any, executor: Any, indirect: Callable[[], TextIO | BinaryIO]) -> None: ... + class AiofilesContextManager(Generic[_T_co, _T_contra, _V_co]): def __init__(self, coro: Coroutine[_T_co, _T_contra, _V_co]) -> None: ... def send(self, value: _T_contra) -> _T_co: ... diff --git a/stubs/aiofiles/aiofiles/tempfile/temptypes.pyi b/stubs/aiofiles/aiofiles/tempfile/temptypes.pyi index 6b66e27ec..211fcafc8 100644 --- a/stubs/aiofiles/aiofiles/tempfile/temptypes.pyi +++ b/stubs/aiofiles/aiofiles/tempfile/temptypes.pyi @@ -38,8 +38,6 @@ class AsyncSpooledTemporaryFile(AsyncBase[_T]): def name(self) -> str: ... @property def newlines(self) -> str: ... - @property - def softspace(self) -> bool: ... # Both should work with `AnyStr`, like in `tempfile`: async def write(self, s: Incomplete) -> int: ... async def writelines(self, iterable: Iterable[Incomplete]) -> None: ... diff --git a/stubs/aiofiles/aiofiles/threadpool/__init__.pyi b/stubs/aiofiles/aiofiles/threadpool/__init__.pyi index 89dcc121a..3176a3a3d 100644 --- a/stubs/aiofiles/aiofiles/threadpool/__init__.pyi +++ b/stubs/aiofiles/aiofiles/threadpool/__init__.pyi @@ -13,8 +13,8 @@ from typing import overload from typing_extensions import Literal, TypeAlias from ..base import AiofilesContextManager -from .binary import AsyncBufferedIOBase, AsyncBufferedReader, AsyncFileIO, _UnknownAsyncBinaryIO -from .text import AsyncTextIOWrapper +from .binary import AsyncBufferedIOBase, AsyncBufferedReader, AsyncFileIO, AsyncIndirectBufferedIOBase, _UnknownAsyncBinaryIO +from .text import AsyncTextIndirectIOWrapper, AsyncTextIOWrapper _Opener: TypeAlias = Callable[[str, int], int] @@ -97,3 +97,10 @@ def open( loop: AbstractEventLoop | None = ..., executor: Incomplete | None = ..., ) -> AiofilesContextManager[None, None, _UnknownAsyncBinaryIO]: ... + +stdin: AsyncTextIndirectIOWrapper +stdout: AsyncTextIndirectIOWrapper +stderr: AsyncTextIndirectIOWrapper +stdin_bytes: AsyncIndirectBufferedIOBase +stdout_bytes: AsyncIndirectBufferedIOBase +stderr_bytes: AsyncIndirectBufferedIOBase diff --git a/stubs/aiofiles/aiofiles/threadpool/binary.pyi b/stubs/aiofiles/aiofiles/threadpool/binary.pyi index c6421325d..db6b63315 100644 --- a/stubs/aiofiles/aiofiles/threadpool/binary.pyi +++ b/stubs/aiofiles/aiofiles/threadpool/binary.pyi @@ -2,8 +2,10 @@ from _typeshed import FileDescriptorOrPath, ReadableBuffer, WriteableBuffer from collections.abc import Iterable from io import FileIO -from ..base import AsyncBase +from ..base import AsyncBase, AsyncIndirectBase +# This class does not exist at runtime and instead these methods are +# all dynamically patched in. class _UnknownAsyncBinaryIO(AsyncBase[bytes]): async def close(self) -> None: ... async def flush(self) -> None: ... @@ -34,8 +36,20 @@ class AsyncBufferedIOBase(_UnknownAsyncBinaryIO): @property def raw(self) -> FileIO: ... +class AsyncIndirectBufferedIOBase(AsyncIndirectBase[bytes], _UnknownAsyncBinaryIO): + async def read1(self, __size: int = ...) -> bytes: ... + def detach(self) -> FileIO: ... + @property + def raw(self) -> FileIO: ... + class AsyncBufferedReader(AsyncBufferedIOBase): async def peek(self, __size: int = ...) -> bytes: ... +class AsyncIndirectBufferedReader(AsyncIndirectBufferedIOBase): + async def peek(self, __size: int = ...) -> bytes: ... + class AsyncFileIO(_UnknownAsyncBinaryIO): async def readall(self) -> bytes: ... + +class AsyncIndirectFileIO(AsyncIndirectBase[bytes], _UnknownAsyncBinaryIO): + async def readall(self) -> bytes: ... diff --git a/stubs/aiofiles/aiofiles/threadpool/text.pyi b/stubs/aiofiles/aiofiles/threadpool/text.pyi index b02cb83fb..3e354d62b 100644 --- a/stubs/aiofiles/aiofiles/threadpool/text.pyi +++ b/stubs/aiofiles/aiofiles/threadpool/text.pyi @@ -2,9 +2,9 @@ from _typeshed import FileDescriptorOrPath from collections.abc import Iterable from typing import BinaryIO -from ..base import AsyncBase +from ..base import AsyncBase, AsyncIndirectBase -class AsyncTextIOWrapper(AsyncBase[str]): +class _UnknownAsyncTextIO(AsyncBase[str]): async def close(self) -> None: ... async def flush(self) -> None: ... async def isatty(self) -> bool: ... @@ -37,3 +37,6 @@ class AsyncTextIOWrapper(AsyncBase[str]): def name(self) -> FileDescriptorOrPath: ... @property def mode(self) -> str: ... + +class AsyncTextIOWrapper(_UnknownAsyncTextIO): ... +class AsyncTextIndirectIOWrapper(AsyncIndirectBase[str], _UnknownAsyncTextIO): ...