mirror of
https://github.com/davidhalter/typeshed.git
synced 2026-02-12 05:01:40 +08:00
Re-organize directory structure (#4971)
See discussion in #2491 Co-authored-by: Ivan Levkivskyi <ilevkivskyi@dropbox.com>
This commit is contained in:
2
stubs/aiofiles/METADATA.toml
Normal file
2
stubs/aiofiles/METADATA.toml
Normal file
@@ -0,0 +1,2 @@
|
||||
version = "0.1"
|
||||
requires = ["types-typing-extensions"]
|
||||
1
stubs/aiofiles/aiofiles/__init__.pyi
Normal file
1
stubs/aiofiles/aiofiles/__init__.pyi
Normal file
@@ -0,0 +1 @@
|
||||
from .threadpool import open as open
|
||||
35
stubs/aiofiles/aiofiles/base.pyi
Normal file
35
stubs/aiofiles/aiofiles/base.pyi
Normal file
@@ -0,0 +1,35 @@
|
||||
from types import CodeType, FrameType, TracebackType, coroutine
|
||||
from typing import Any, Coroutine, Generator, Generic, Iterator, Optional, Type, TypeVar, Union
|
||||
|
||||
_T = TypeVar("_T")
|
||||
_T_co = TypeVar("_T_co", covariant=True)
|
||||
_V_co = TypeVar("_V_co", covariant=True)
|
||||
_T_contra = TypeVar("_T_contra", contravariant=True)
|
||||
|
||||
class AsyncBase(Generic[_T]):
|
||||
def __init__(self, file: str, loop: Any, executor: Any) -> None: ...
|
||||
async def __aiter__(self) -> Iterator[_T]: ...
|
||||
async def __anext__(self) -> _T: ...
|
||||
|
||||
class AiofilesContextManager(Generic[_T_co, _T_contra, _V_co]):
|
||||
def __init__(self, coro: Coroutine[_T_co, _T_contra, _V_co]) -> 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[_T_co, _T_contra, _V_co]]: ...
|
||||
def __await__(self) -> Generator[Any, None, _V_co]: ...
|
||||
async def __anext__(self) -> _V_co: ...
|
||||
async def __aenter__(self) -> _V_co: ...
|
||||
async def __aexit__(
|
||||
self, exc_type: Optional[Type[BaseException]], exc_val: Optional[BaseException], exc_tb: Optional[TracebackType]
|
||||
) -> None: ...
|
||||
26
stubs/aiofiles/aiofiles/os.pyi
Normal file
26
stubs/aiofiles/aiofiles/os.pyi
Normal 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: ...
|
||||
91
stubs/aiofiles/aiofiles/threadpool/__init__.pyi
Normal file
91
stubs/aiofiles/aiofiles/threadpool/__init__.pyi
Normal file
@@ -0,0 +1,91 @@
|
||||
from _typeshed import AnyPath, OpenBinaryMode, OpenBinaryModeReading, OpenBinaryModeUpdating, OpenBinaryModeWriting, OpenTextMode
|
||||
from asyncio import AbstractEventLoop
|
||||
from typing import Any, Callable, Optional, TypeVar, Union, overload
|
||||
from typing_extensions import Literal
|
||||
|
||||
from ..base import AiofilesContextManager
|
||||
from .binary import AsyncBufferedIOBase, AsyncBufferedReader, AsyncFileIO, _UnknownAsyncBinaryIO
|
||||
from .text import AsyncTextIOWrapper
|
||||
|
||||
_OpenFile = TypeVar("_OpenFile", bound=Union[AnyPath, int])
|
||||
_Opener = Callable[[str, int], int]
|
||||
|
||||
# Text mode: always returns AsyncTextIOWrapper
|
||||
@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[AbstractEventLoop] = ...,
|
||||
executor: Optional[Any] = ...,
|
||||
) -> AiofilesContextManager[None, None, AsyncTextIOWrapper]: ...
|
||||
|
||||
# Unbuffered binary: returns a FileIO
|
||||
@overload
|
||||
def open(
|
||||
file: _OpenFile,
|
||||
mode: OpenBinaryMode,
|
||||
buffering: Literal[0],
|
||||
encoding: None = ...,
|
||||
errors: None = ...,
|
||||
newline: None = ...,
|
||||
closefd: bool = ...,
|
||||
opener: Optional[_Opener] = ...,
|
||||
*,
|
||||
loop: Optional[AbstractEventLoop] = ...,
|
||||
executor: Optional[Any] = ...,
|
||||
) -> AiofilesContextManager[None, None, AsyncFileIO]: ...
|
||||
|
||||
# Buffered binary reading/updating: AsyncBufferedReader
|
||||
@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[AbstractEventLoop] = ...,
|
||||
executor: Optional[Any] = ...,
|
||||
) -> AiofilesContextManager[None, None, AsyncBufferedReader]: ...
|
||||
|
||||
# Buffered binary writing: AsyncBufferedIOBase
|
||||
@overload
|
||||
def open(
|
||||
file: _OpenFile,
|
||||
mode: OpenBinaryModeWriting,
|
||||
buffering: Literal[-1, 1] = ...,
|
||||
encoding: None = ...,
|
||||
errors: None = ...,
|
||||
newline: None = ...,
|
||||
closefd: bool = ...,
|
||||
opener: Optional[_Opener] = ...,
|
||||
*,
|
||||
loop: Optional[AbstractEventLoop] = ...,
|
||||
executor: Optional[Any] = ...,
|
||||
) -> AiofilesContextManager[None, None, AsyncBufferedIOBase]: ...
|
||||
|
||||
# Buffering cannot be determined: fall back to _UnknownAsyncBinaryIO
|
||||
@overload
|
||||
def open(
|
||||
file: _OpenFile,
|
||||
mode: OpenBinaryMode,
|
||||
buffering: int,
|
||||
encoding: None = ...,
|
||||
errors: None = ...,
|
||||
newline: None = ...,
|
||||
closefd: bool = ...,
|
||||
opener: Optional[_Opener] = ...,
|
||||
*,
|
||||
loop: Optional[AbstractEventLoop] = ...,
|
||||
executor: Optional[Any] = ...,
|
||||
) -> AiofilesContextManager[None, None, _UnknownAsyncBinaryIO]: ...
|
||||
41
stubs/aiofiles/aiofiles/threadpool/binary.pyi
Normal file
41
stubs/aiofiles/aiofiles/threadpool/binary.pyi
Normal file
@@ -0,0 +1,41 @@
|
||||
from _typeshed import AnyPath, ReadableBuffer, WriteableBuffer
|
||||
from io import FileIO
|
||||
from typing import Iterable, List, Optional, Union
|
||||
|
||||
from ..base import AsyncBase
|
||||
|
||||
class _UnknownAsyncBinaryIO(AsyncBase[bytes]):
|
||||
async def close(self) -> None: ...
|
||||
async def flush(self) -> None: ...
|
||||
async def isatty(self) -> bool: ...
|
||||
async def read(self, __size: int = ...) -> bytes: ...
|
||||
async def readinto(self, __buffer: WriteableBuffer) -> Optional[int]: ...
|
||||
async def readline(self, __size: Optional[int] = ...) -> bytes: ...
|
||||
async def readlines(self, __hint: int = ...) -> List[bytes]: ...
|
||||
async def seek(self, __offset: int, __whence: int = ...) -> int: ...
|
||||
async def seekable(self) -> bool: ...
|
||||
async def tell(self) -> int: ...
|
||||
async def truncate(self, __size: Optional[int] = ...) -> int: ...
|
||||
async def writable(self) -> bool: ...
|
||||
async def write(self, __b: ReadableBuffer) -> int: ...
|
||||
async def writelines(self, __lines: Iterable[ReadableBuffer]) -> None: ...
|
||||
def fileno(self) -> int: ...
|
||||
def readable(self) -> bool: ...
|
||||
@property
|
||||
def closed(self) -> bool: ...
|
||||
@property
|
||||
def mode(self) -> str: ...
|
||||
@property
|
||||
def name(self) -> Union[AnyPath, int]: ...
|
||||
|
||||
class AsyncBufferedIOBase(_UnknownAsyncBinaryIO):
|
||||
async def read1(self, __size: int = ...) -> bytes: ...
|
||||
def detach(self) -> FileIO: ...
|
||||
@property
|
||||
def raw(self) -> FileIO: ...
|
||||
|
||||
class AsyncBufferedReader(AsyncBufferedIOBase):
|
||||
async def peek(self, __size: int = ...) -> bytes: ...
|
||||
|
||||
class AsyncFileIO(_UnknownAsyncBinaryIO):
|
||||
async def readall(self) -> bytes: ...
|
||||
38
stubs/aiofiles/aiofiles/threadpool/text.pyi
Normal file
38
stubs/aiofiles/aiofiles/threadpool/text.pyi
Normal file
@@ -0,0 +1,38 @@
|
||||
from _typeshed import AnyPath
|
||||
from typing import BinaryIO, Iterable, List, Optional, Tuple, Union
|
||||
|
||||
from ..base import AsyncBase
|
||||
|
||||
class AsyncTextIOWrapper(AsyncBase[str]):
|
||||
async def close(self) -> None: ...
|
||||
async def flush(self) -> None: ...
|
||||
async def isatty(self) -> bool: ...
|
||||
async def read(self, __size: Optional[int] = ...) -> str: ...
|
||||
async def readline(self, __size: int = ...) -> str: ...
|
||||
async def readlines(self, __hint: int = ...) -> List[str]: ...
|
||||
async def seek(self, __offset: int, __whence: int = ...) -> int: ...
|
||||
async def seekable(self) -> bool: ...
|
||||
async def tell(self) -> int: ...
|
||||
async def truncate(self, __size: Optional[int] = ...) -> int: ...
|
||||
async def writable(self) -> bool: ...
|
||||
async def write(self, __b: str) -> int: ...
|
||||
async def writelines(self, __lines: Iterable[str]) -> None: ...
|
||||
def detach(self) -> BinaryIO: ...
|
||||
def fileno(self) -> int: ...
|
||||
def readable(self) -> bool: ...
|
||||
@property
|
||||
def buffer(self) -> BinaryIO: ...
|
||||
@property
|
||||
def closed(self) -> bool: ...
|
||||
@property
|
||||
def encoding(self) -> str: ...
|
||||
@property
|
||||
def errors(self) -> Optional[str]: ...
|
||||
@property
|
||||
def line_buffering(self) -> bool: ...
|
||||
@property
|
||||
def newlines(self) -> Union[str, Tuple[str, ...], None]: ...
|
||||
@property
|
||||
def name(self) -> Union[AnyPath, int]: ...
|
||||
@property
|
||||
def mode(self) -> str: ...
|
||||
Reference in New Issue
Block a user