From 13e31aa3bf24c46c84f1a788022551587b5d84d1 Mon Sep 17 00:00:00 2001 From: Joseph Young <80432516+jpy-git@users.noreply.github.com> Date: Thu, 13 Jan 2022 10:31:19 +0000 Subject: [PATCH] Add stubs for aiofiles.os.path (#6787) --- stubs/aiofiles/@tests/stubtest_allowlist.txt | 9 +++++++++ stubs/aiofiles/aiofiles/os.pyi | 15 +++++++++++---- stubs/aiofiles/aiofiles/ospath.pyi | 15 +++++++++++++++ 3 files changed, 35 insertions(+), 4 deletions(-) create mode 100644 stubs/aiofiles/aiofiles/ospath.pyi diff --git a/stubs/aiofiles/@tests/stubtest_allowlist.txt b/stubs/aiofiles/@tests/stubtest_allowlist.txt index aafa18a41..694c4fc5e 100644 --- a/stubs/aiofiles/@tests/stubtest_allowlist.txt +++ b/stubs/aiofiles/@tests/stubtest_allowlist.txt @@ -40,3 +40,12 @@ aiofiles.os.mkdir aiofiles.os.makedirs aiofiles.os.rmdir aiofiles.os.removedirs +aiofiles.ospath.exists +aiofiles.ospath.isfile +aiofiles.ospath.isdir +aiofiles.ospath.getsize +aiofiles.ospath.getmtime +aiofiles.ospath.getatime +aiofiles.ospath.getctime +aiofiles.ospath.samefile +aiofiles.ospath.sameopenfile diff --git a/stubs/aiofiles/aiofiles/os.pyi b/stubs/aiofiles/aiofiles/os.pyi index 1dc40a918..761d42556 100644 --- a/stubs/aiofiles/aiofiles/os.pyi +++ b/stubs/aiofiles/aiofiles/os.pyi @@ -4,10 +4,12 @@ from asyncio.events import AbstractEventLoop from os import stat_result from typing import Any, Sequence, Union, overload +from . import ospath as path + _FdOrAnyPath = Union[int, StrOrBytesPath] async def stat( - path: _FdOrAnyPath, + path: _FdOrAnyPath, # noqa: F811 *, dir_fd: int | None = ..., follow_symlinks: bool = ..., @@ -33,16 +35,21 @@ async def replace( executor: Any = ..., ) -> None: ... async def remove( - path: StrOrBytesPath, *, dir_fd: int | None = ..., loop: AbstractEventLoop | None = ..., executor: Any = ... + path: StrOrBytesPath, *, dir_fd: int | None = ..., loop: AbstractEventLoop | None = ..., executor: Any = ... # noqa: F811 ) -> None: ... async def mkdir( - path: StrOrBytesPath, mode: int = ..., *, dir_fd: int | None = ..., loop: AbstractEventLoop | None = ..., executor: Any = ... + path: StrOrBytesPath, # noqa: F811 + mode: int = ..., + *, + dir_fd: int | None = ..., + loop: AbstractEventLoop | None = ..., + executor: Any = ..., # noqa: F811 ) -> 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 = ... + path: StrOrBytesPath, *, dir_fd: int | None = ..., loop: AbstractEventLoop | None = ..., executor: Any = ... # noqa: F811 ) -> None: ... async def removedirs(name: StrOrBytesPath, *, loop: AbstractEventLoop | None = ..., executor: Any = ...) -> None: ... diff --git a/stubs/aiofiles/aiofiles/ospath.pyi b/stubs/aiofiles/aiofiles/ospath.pyi new file mode 100644 index 000000000..4b5735cfa --- /dev/null +++ b/stubs/aiofiles/aiofiles/ospath.pyi @@ -0,0 +1,15 @@ +from _typeshed import StrOrBytesPath +from asyncio.events import AbstractEventLoop +from typing import Any + +async def exists(path: StrOrBytesPath | int, *, loop: AbstractEventLoop | None = ..., executor: Any = ...) -> bool: ... +async def isfile(path: StrOrBytesPath | int, *, loop: AbstractEventLoop | None = ..., executor: Any = ...) -> bool: ... +async def isdir(s: StrOrBytesPath | int, *, loop: AbstractEventLoop | None = ..., executor: Any = ...) -> bool: ... +async def getsize(filename: StrOrBytesPath | int, *, loop: AbstractEventLoop | None = ..., executor: Any = ...) -> int: ... +async def getmtime(filename: StrOrBytesPath | int, *, loop: AbstractEventLoop | None = ..., executor: Any = ...) -> float: ... +async def getatime(filename: StrOrBytesPath | int, *, loop: AbstractEventLoop | None = ..., executor: Any = ...) -> float: ... +async def getctime(filename: StrOrBytesPath | int, *, loop: AbstractEventLoop | None = ..., executor: Any = ...) -> float: ... +async def samefile( + f1: StrOrBytesPath | int, f2: StrOrBytesPath | int, *, loop: AbstractEventLoop | None = ..., executor: Any = ... +) -> bool: ... +async def sameopenfile(fp1: int, fp2: int, *, loop: AbstractEventLoop | None = ..., executor: Any = ...) -> bool: ...