Skip to content

Commit

Permalink
Update aiofiles for v23.1.* (#9711)
Browse files Browse the repository at this point in the history
Co-authored-by: Mehdi Drissi <mdrissi@snapchat.com>
Co-authored-by: Alex Waygood <Alex.Waygood@Gmail.com>
  • Loading branch information
3 people authored Mar 9, 2023
1 parent a47dd76 commit 390058e
Show file tree
Hide file tree
Showing 8 changed files with 71 additions and 11 deletions.
27 changes: 27 additions & 0 deletions stubs/aiofiles/@tests/stubtest_allowlist.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand All @@ -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
Expand Down
2 changes: 1 addition & 1 deletion stubs/aiofiles/METADATA.toml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
version = "22.1.*"
version = "23.1.*"

[tool.stubtest]
# linux and darwin are equivalent
Expand Down
10 changes: 9 additions & 1 deletion stubs/aiofiles/aiofiles/__init__.pyi
Original file line number Diff line number Diff line change
@@ -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,
)
7 changes: 5 additions & 2 deletions stubs/aiofiles/aiofiles/base.pyi
Original file line number Diff line number Diff line change
@@ -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")
Expand All @@ -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: ...
Expand Down
2 changes: 0 additions & 2 deletions stubs/aiofiles/aiofiles/tempfile/temptypes.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -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: ...
Expand Down
11 changes: 9 additions & 2 deletions stubs/aiofiles/aiofiles/threadpool/__init__.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -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]

Expand Down Expand Up @@ -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
16 changes: 15 additions & 1 deletion stubs/aiofiles/aiofiles/threadpool/binary.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -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: ...
Expand Down Expand Up @@ -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: ...
7 changes: 5 additions & 2 deletions stubs/aiofiles/aiofiles/threadpool/text.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -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: ...
Expand Down Expand Up @@ -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): ...

0 comments on commit 390058e

Please sign in to comment.