Added stubs for aiofiles package (#4421)

This commit is contained in:
Eric Traut
2020-08-19 08:33:33 -07:00
committed by GitHub
parent 6a06ff53f0
commit 52e18e856c
6 changed files with 150 additions and 0 deletions

2
third_party/3/aiofiles/__init__.pyi vendored Normal file
View File

@@ -0,0 +1,2 @@
from . import _os as os
from .threadpool import open as open

26
third_party/3/aiofiles/_os.pyi vendored Normal file
View File

@@ -0,0 +1,26 @@
import sys
from _typeshed import AnyPath
from os import stat_result
from typing import Optional, Sequence, Union, overload
_FdOrAnyPath = Union[int, AnyPath]
async def stat(path: _FdOrAnyPath, *, dir_fd: Optional[int] = ..., follow_symlinks: bool = ...) -> stat_result: ...
async def rename(src: AnyPath, dst: AnyPath, *, src_dir_fd: Optional[int] = ..., dst_dir_fd: Optional[int] = ...) -> None: ...
async def remove(path: AnyPath, *, dir_fd: Optional[int] = ...) -> None: ...
async def mkdir(path: AnyPath, mode: int = ..., *, dir_fd: Optional[int] = ...) -> None: ...
async def rmdir(path: AnyPath, *, dir_fd: Optional[int] = ...) -> None: ...
if sys.platform != "win32":
@overload
async def sendfile(__out_fd: int, __in_fd: int, offset: Optional[int], count: int) -> int: ...
@overload
async def sendfile(
__out_fd: int,
__in_fd: int,
offset: int,
count: int,
headers: Sequence[bytes] = ...,
trailers: Sequence[bytes] = ...,
flags: int = ...,
) -> int: ...

34
third_party/3/aiofiles/base.pyi vendored Normal file
View File

@@ -0,0 +1,34 @@
from types import CodeType, FrameType, TracebackType, coroutine
from typing import Any, Coroutine, Generator, Generic, Iterator, Optional, Type, TypeVar, Union
_T_co = TypeVar("_T_co", covariant=True)
_V_co = TypeVar("_V_co", covariant=True)
_T_contra = TypeVar("_T_contra", contravariant=True)
class AsyncBase:
def __init__(self, file: str, loop: Any, executor: Any) -> None: ...
async def __aiter__(self) -> Iterator[str]: ...
async def __anext__(self) -> str: ...
class AiofilesContextManager(Generic[_V_co, _T_co, _T_contra]):
def __init__(self, __coro: Coroutine[_V_co, _T_co, _T_contra]) -> None: ...
def send(self, __value: _T_contra) -> _T_co: ...
def throw(
self, __typ: Type[BaseException], __val: Union[BaseException, object] = ..., tb: Optional[TracebackType] = ...,
) -> _T_co: ...
def close(self) -> None: ...
@property
def gi_frame(self) -> FrameType: ...
@property
def gi_running(self) -> bool: ...
@property
def gi_code(self) -> CodeType: ...
def __next__(self) -> _T_co: ...
@coroutine
def __iter__(self) -> Iterator[Coroutine[_V_co, _T_co, _T_contra]]: ...
def __await__(self) -> Generator[Any, None, _T_co]: ...
async def __anext__(self) -> Coroutine[_V_co, _T_co, _T_contra]: ...
async def __aenter__(self) -> Coroutine[_V_co, _T_co, _T_contra]: ...
async def __aexit__(
self, exc_type: Optional[Type[BaseException]], exc_val: Optional[BaseException], exc_tb: Optional[TracebackType],
) -> None: ...

View File

@@ -0,0 +1,80 @@
from _typeshed import AnyPath, OpenBinaryMode, OpenBinaryModeReading, OpenBinaryModeUpdating, OpenBinaryModeWriting, OpenTextMode
from typing import Any, Callable, Optional, Union, overload
from typing_extensions import Literal
from ..base import AsyncBase
from .binary import AsyncBufferedIOBase, AsyncBufferedReader, AsyncFileIO
from .text import AsyncTextIOWrapper
_OpenFile = Union[AnyPath, int]
_Opener = Callable[[str, int], int]
@overload
def open(
file: _OpenFile,
mode: OpenTextMode = ...,
buffering: int = ...,
encoding: Optional[str] = ...,
errors: Optional[str] = ...,
newline: Optional[str] = ...,
closefd: bool = ...,
opener: Optional[_Opener] = ...,
*,
loop: Optional[Any] = ...,
executor: Optional[Any] = ...,
) -> AsyncTextIOWrapper: ...
@overload
def open(
file: _OpenFile,
mode: OpenBinaryMode,
buffering: Literal[0],
encoding: None = ...,
errors: None = ...,
newline: None = ...,
closefd: bool = ...,
opener: Optional[_Opener] = ...,
*,
loop: Optional[Any] = ...,
executor: Optional[Any] = ...,
) -> AsyncFileIO: ...
@overload
def open(
file: _OpenFile,
mode: OpenBinaryModeWriting,
buffering: Literal[-1, 1] = ...,
encoding: None = ...,
errors: None = ...,
newline: None = ...,
closefd: bool = ...,
opener: Optional[_Opener] = ...,
*,
loop: Optional[Any] = ...,
executor: Optional[Any] = ...,
) -> AsyncBufferedIOBase: ...
@overload
def open(
file: _OpenFile,
mode: Union[OpenBinaryModeReading, OpenBinaryModeUpdating],
buffering: Literal[-1, 1] = ...,
encoding: None = ...,
errors: None = ...,
newline: None = ...,
closefd: bool = ...,
opener: Optional[_Opener] = ...,
*,
loop: Optional[Any] = ...,
executor: Optional[Any] = ...,
) -> AsyncBufferedReader: ...
@overload
def open(
file: _OpenFile,
mode: OpenBinaryMode,
buffering: int,
encoding: None = ...,
errors: None = ...,
newline: None = ...,
closefd: bool = ...,
opener: Optional[_Opener] = ...,
*,
loop: Optional[Any] = ...,
executor: Optional[Any] = ...,
) -> AsyncBase: ...

View File

@@ -0,0 +1,5 @@
from ..base import AsyncBase
class AsyncBufferedIOBase(AsyncBase): ...
class AsyncBufferedReader(AsyncBufferedIOBase): ...
class AsyncFileIO(AsyncBase): ...

View File

@@ -0,0 +1,3 @@
from ..base import AsyncBase
class AsyncTextIOWrapper(AsyncBase): ...