From 695d41f4870aede6e7027cf23bb65b07b59eedc6 Mon Sep 17 00:00:00 2001 From: Sebastian Rittau Date: Wed, 16 Aug 2023 13:05:42 +0200 Subject: [PATCH] Bump aiofiles to 23.2.* (#10584) --- stubs/aiofiles/@tests/stubtest_allowlist.txt | 3 -- .../@tests/stubtest_allowlist_win32.txt | 5 +++ stubs/aiofiles/METADATA.toml | 2 +- stubs/aiofiles/aiofiles/os.pyi | 31 +++++++++++++++++++ stubs/aiofiles/aiofiles/ospath.pyi | 6 +++- .../aiofiles/aiofiles/tempfile/temptypes.pyi | 1 - stubs/aiofiles/aiofiles/threadpool/utils.pyi | 1 - 7 files changed, 42 insertions(+), 7 deletions(-) create mode 100644 stubs/aiofiles/@tests/stubtest_allowlist_win32.txt diff --git a/stubs/aiofiles/@tests/stubtest_allowlist.txt b/stubs/aiofiles/@tests/stubtest_allowlist.txt index 29651389f..3bf7029b4 100644 --- a/stubs/aiofiles/@tests/stubtest_allowlist.txt +++ b/stubs/aiofiles/@tests/stubtest_allowlist.txt @@ -93,6 +93,3 @@ aiofiles.tempfile.temptypes.AsyncTemporaryDirectory.cleanup # Metaclass differs: aiofiles.base.AiofilesContextManager aiofiles.tempfile.AiofilesContextManagerTempDir - -# Helper decorator, too complex to type -aiofiles.os.wrap diff --git a/stubs/aiofiles/@tests/stubtest_allowlist_win32.txt b/stubs/aiofiles/@tests/stubtest_allowlist_win32.txt new file mode 100644 index 000000000..7bd650ce1 --- /dev/null +++ b/stubs/aiofiles/@tests/stubtest_allowlist_win32.txt @@ -0,0 +1,5 @@ +# At runtime, __all__ includes some items that are not available on Windows. +# https://github.com/Tinche/aiofiles/pull/174 +aiofiles.os.__all__ +aiofiles.os.sendfile +aiofiles.os.statvfs diff --git a/stubs/aiofiles/METADATA.toml b/stubs/aiofiles/METADATA.toml index f9b51ecc6..950f1bd80 100644 --- a/stubs/aiofiles/METADATA.toml +++ b/stubs/aiofiles/METADATA.toml @@ -1,4 +1,4 @@ -version = "23.1.*" +version = "23.2.*" upstream_repository = "https://github.com/Tinche/aiofiles" [tool.stubtest] diff --git a/stubs/aiofiles/aiofiles/os.pyi b/stubs/aiofiles/aiofiles/os.pyi index 27a3c70a4..54e601040 100644 --- a/stubs/aiofiles/aiofiles/os.pyi +++ b/stubs/aiofiles/aiofiles/os.pyi @@ -6,6 +6,31 @@ from os import _ScandirIterator, stat_result from typing import Any, AnyStr, overload from aiofiles import ospath +from aiofiles.ospath import wrap as wrap + +__all__ = [ + "path", + "stat", + "rename", + "renames", + "replace", + "remove", + "unlink", + "mkdir", + "makedirs", + "rmdir", + "removedirs", + "link", + "symlink", + "readlink", + "listdir", + "scandir", + "access", + "wrap", +] + +if sys.platform != "win32": + __all__ += ["statvfs", "sendfile"] path = ospath @@ -90,8 +115,13 @@ async def listdir(path: StrPath | None, *, loop: AbstractEventLoop | None = ..., async def listdir(path: BytesPath, *, loop: AbstractEventLoop | None = ..., executor: Any = ...) -> list[bytes]: ... @overload async def listdir(path: int, *, loop: AbstractEventLoop | None = ..., executor: Any = ...) -> list[str]: ... +async def access( + path: FileDescriptorOrPath, mode: int, *, dir_fd: int | None = None, effective_ids: bool = False, follow_symlinks: bool = True +) -> bool: ... if sys.platform != "win32": + from os import statvfs_result + @overload async def sendfile( out_fd: int, in_fd: int, offset: int | None, count: int, *, loop: AbstractEventLoop | None = ..., executor: Any = ... @@ -109,3 +139,4 @@ if sys.platform != "win32": loop: AbstractEventLoop | None = ..., executor: Any = ..., ) -> int: ... # FreeBSD and Mac OS X only + async def statvfs(path: FileDescriptorOrPath) -> statvfs_result: ... # Unix only diff --git a/stubs/aiofiles/aiofiles/ospath.pyi b/stubs/aiofiles/aiofiles/ospath.pyi index e58e72898..c7f3912e9 100644 --- a/stubs/aiofiles/aiofiles/ospath.pyi +++ b/stubs/aiofiles/aiofiles/ospath.pyi @@ -1,7 +1,11 @@ from _typeshed import FileDescriptorOrPath from asyncio.events import AbstractEventLoop -from typing import Any +from collections.abc import Awaitable, Callable +from typing import Any, TypeVar +_R = TypeVar("_R") + +def wrap(func: Callable[..., _R]) -> Callable[..., Awaitable[_R]]: ... async def exists(path: FileDescriptorOrPath, *, loop: AbstractEventLoop | None = ..., executor: Any = ...) -> bool: ... async def isfile(path: FileDescriptorOrPath, *, loop: AbstractEventLoop | None = ..., executor: Any = ...) -> bool: ... async def isdir(s: FileDescriptorOrPath, *, loop: AbstractEventLoop | None = ..., executor: Any = ...) -> bool: ... diff --git a/stubs/aiofiles/aiofiles/tempfile/temptypes.pyi b/stubs/aiofiles/aiofiles/tempfile/temptypes.pyi index bb9fdcfca..707d2ec66 100644 --- a/stubs/aiofiles/aiofiles/tempfile/temptypes.pyi +++ b/stubs/aiofiles/aiofiles/tempfile/temptypes.pyi @@ -2,7 +2,6 @@ from _typeshed import Incomplete, OpenBinaryMode from asyncio import AbstractEventLoop from collections.abc import Generator, Iterable from tempfile import TemporaryDirectory -from types import coroutine as coroutine from typing import TypeVar from aiofiles.base import AsyncBase as AsyncBase diff --git a/stubs/aiofiles/aiofiles/threadpool/utils.pyi b/stubs/aiofiles/aiofiles/threadpool/utils.pyi index afff76d0d..438a6851e 100644 --- a/stubs/aiofiles/aiofiles/threadpool/utils.pyi +++ b/stubs/aiofiles/aiofiles/threadpool/utils.pyi @@ -1,5 +1,4 @@ from collections.abc import Callable -from types import coroutine as coroutine from typing import TypeVar _T = TypeVar("_T", bound=type)