add typing support to more aiofiles wrapped functions (#10175)

add stubs for missing functions:

- renames
- unlink
- link
- listdir
This commit is contained in:
Abtin
2023-05-22 16:44:00 +02:00
committed by GitHub
parent 15df17098a
commit 31f4b8cf80
2 changed files with 41 additions and 1 deletions

View File

@@ -58,13 +58,19 @@ aiofiles.threadpool.text.AsyncTextIndirectIOWrapper.writable
# These functions get the wrong signature from functools.wraps()
aiofiles.os.stat
aiofiles.os.rename
aiofiles.os.renames
aiofiles.os.replace
aiofiles.os.remove
aiofiles.os.unlink
aiofiles.os.mkdir
aiofiles.os.makedirs
aiofiles.os.link
aiofiles.os.symlink
aiofiles.os.readlink
aiofiles.os.rmdir
aiofiles.os.removedirs
aiofiles.os.scandir
aiofiles.os.listdir
aiofiles.ospath.exists
aiofiles.ospath.isfile
aiofiles.ospath.isdir

View File

@@ -1,5 +1,5 @@
import sys
from _typeshed import FileDescriptorOrPath, GenericPath, ReadableBuffer, StrOrBytesPath
from _typeshed import BytesPath, FileDescriptorOrPath, GenericPath, ReadableBuffer, StrOrBytesPath, StrPath
from asyncio.events import AbstractEventLoop
from collections.abc import Sequence
from os import _ScandirIterator, stat_result
@@ -26,6 +26,9 @@ async def rename(
loop: AbstractEventLoop | None = ...,
executor: Any = ...,
) -> None: ...
async def renames(
old: StrOrBytesPath, new: StrOrBytesPath, loop: AbstractEventLoop | None = ..., executor: Any = ...
) -> None: ...
async def replace(
src: StrOrBytesPath,
dst: StrOrBytesPath,
@@ -38,12 +41,37 @@ async def replace(
async def remove(
path: StrOrBytesPath, *, dir_fd: int | None = None, loop: AbstractEventLoop | None = ..., executor: Any = ...
) -> None: ...
async def unlink(
path: StrOrBytesPath, *, dir_fd: int | None = ..., loop: AbstractEventLoop | None = ..., executor: Any = ...
) -> None: ...
async def mkdir(
path: StrOrBytesPath, mode: int = 511, *, dir_fd: int | None = None, loop: AbstractEventLoop | None = ..., executor: Any = ...
) -> None: ...
async def makedirs(
name: StrOrBytesPath, mode: int = 511, exist_ok: bool = False, *, loop: AbstractEventLoop | None = ..., executor: Any = ...
) -> None: ...
async def link(
src: StrOrBytesPath,
dst: StrOrBytesPath,
*,
src_dir_fd: int | None = ...,
dst_dir_fd: int | None = ...,
follow_symlinks: bool = ...,
loop: AbstractEventLoop | None = ...,
executor: Any = ...,
) -> None: ...
async def symlink(
src: StrOrBytesPath,
dst: StrOrBytesPath,
target_is_directory: bool = ...,
*,
dir_fd: int | None = ...,
loop: AbstractEventLoop | None = ...,
executor: Any = ...,
) -> None: ...
async def readlink(
path: AnyStr, *, dir_fd: int | None = ..., loop: AbstractEventLoop | None = ..., executor: Any = ...
) -> AnyStr: ...
async def rmdir(
path: StrOrBytesPath, *, dir_fd: int | None = None, loop: AbstractEventLoop | None = ..., executor: Any = ...
) -> None: ...
@@ -56,6 +84,12 @@ async def scandir(path: int, *, loop: AbstractEventLoop | None = ..., executor:
async def scandir(
path: GenericPath[AnyStr], *, loop: AbstractEventLoop | None = ..., executor: Any = ...
) -> _ScandirIterator[AnyStr]: ...
@overload
async def listdir(path: StrPath | None, *, loop: AbstractEventLoop | None = ..., executor: Any = ...) -> list[str]: ...
@overload
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]: ...
if sys.platform != "win32":
@overload