From 45387704041406852f2bae5c8986811691eb5f7b Mon Sep 17 00:00:00 2001 From: Joseph Young <80432516+jpy-git@users.noreply.github.com> Date: Sun, 2 Jan 2022 18:08:00 +0000 Subject: [PATCH] Add missing functions and keyword arguments to aiofiles.os (#6785) Co-authored-by: Akuli --- stubs/aiofiles/@tests/stubtest_allowlist.txt | 10 ++++ stubs/aiofiles/METADATA.toml | 2 +- stubs/aiofiles/aiofiles/os.pyi | 52 +++++++++++++++++--- 3 files changed, 56 insertions(+), 8 deletions(-) diff --git a/stubs/aiofiles/@tests/stubtest_allowlist.txt b/stubs/aiofiles/@tests/stubtest_allowlist.txt index ea7fd914c..aafa18a41 100644 --- a/stubs/aiofiles/@tests/stubtest_allowlist.txt +++ b/stubs/aiofiles/@tests/stubtest_allowlist.txt @@ -30,3 +30,13 @@ aiofiles.threadpool.text.AsyncTextIOWrapper.readable aiofiles.threadpool.text.AsyncTextIOWrapper.seekable aiofiles.threadpool.text.AsyncTextIOWrapper.tell aiofiles.threadpool.text.AsyncTextIOWrapper.writable + +# These functions get the wrong signature from functools.wraps() +aiofiles.os.stat +aiofiles.os.rename +aiofiles.os.replace +aiofiles.os.remove +aiofiles.os.mkdir +aiofiles.os.makedirs +aiofiles.os.rmdir +aiofiles.os.removedirs diff --git a/stubs/aiofiles/METADATA.toml b/stubs/aiofiles/METADATA.toml index 7431acfe0..29511ee7d 100644 --- a/stubs/aiofiles/METADATA.toml +++ b/stubs/aiofiles/METADATA.toml @@ -1 +1 @@ -version = "0.7.*" +version = "0.8.*" diff --git a/stubs/aiofiles/aiofiles/os.pyi b/stubs/aiofiles/aiofiles/os.pyi index f1bd47bf5..1dc40a918 100644 --- a/stubs/aiofiles/aiofiles/os.pyi +++ b/stubs/aiofiles/aiofiles/os.pyi @@ -1,21 +1,56 @@ import sys from _typeshed import StrOrBytesPath +from asyncio.events import AbstractEventLoop from os import stat_result -from typing import Sequence, Union, overload +from typing import Any, Sequence, Union, overload _FdOrAnyPath = Union[int, StrOrBytesPath] -async def stat(path: _FdOrAnyPath, *, dir_fd: int | None = ..., follow_symlinks: bool = ...) -> stat_result: ... +async def stat( + path: _FdOrAnyPath, + *, + dir_fd: int | None = ..., + follow_symlinks: bool = ..., + loop: AbstractEventLoop | None = ..., + executor: Any = ..., +) -> stat_result: ... async def rename( - src: StrOrBytesPath, dst: StrOrBytesPath, *, src_dir_fd: int | None = ..., dst_dir_fd: int | None = ... + src: StrOrBytesPath, + dst: StrOrBytesPath, + *, + src_dir_fd: int | None = ..., + dst_dir_fd: int | None = ..., + loop: AbstractEventLoop | None = ..., + executor: Any = ..., ) -> None: ... -async def remove(path: StrOrBytesPath, *, dir_fd: int | None = ...) -> None: ... -async def mkdir(path: StrOrBytesPath, mode: int = ..., *, dir_fd: int | None = ...) -> None: ... -async def rmdir(path: StrOrBytesPath, *, dir_fd: int | None = ...) -> None: ... +async def replace( + src: StrOrBytesPath, + dst: StrOrBytesPath, + *, + src_dir_fd: int | None = ..., + dst_dir_fd: int | None = ..., + loop: AbstractEventLoop | None = ..., + executor: Any = ..., +) -> None: ... +async def remove( + path: StrOrBytesPath, *, dir_fd: int | None = ..., loop: AbstractEventLoop | None = ..., executor: Any = ... +) -> None: ... +async def mkdir( + path: StrOrBytesPath, mode: int = ..., *, dir_fd: int | None = ..., loop: AbstractEventLoop | None = ..., executor: Any = ... +) -> None: ... +async def makedirs( + name: StrOrBytesPath, mode: int = ..., exist_ok: bool = ..., *, loop: AbstractEventLoop | None = ..., executor: Any = ... +) -> None: ... +async def rmdir( + path: StrOrBytesPath, *, dir_fd: int | None = ..., loop: AbstractEventLoop | None = ..., executor: Any = ... +) -> None: ... +async def removedirs(name: StrOrBytesPath, *, loop: AbstractEventLoop | None = ..., executor: Any = ...) -> None: ... if sys.platform != "win32": @overload - async def sendfile(out_fd: int, in_fd: int, offset: int | None, count: int) -> int: ... + async def sendfile( + out_fd: int, in_fd: int, offset: int | None, count: int, *, loop: AbstractEventLoop | None = ..., executor: Any = ... + ) -> int: ... @overload async def sendfile( out_fd: int, @@ -25,4 +60,7 @@ if sys.platform != "win32": headers: Sequence[bytes] = ..., trailers: Sequence[bytes] = ..., flags: int = ..., + *, + loop: AbstractEventLoop | None = ..., + executor: Any = ..., ) -> int: ... # FreeBSD and Mac OS X only