mirror of
https://github.com/davidhalter/typeshed.git
synced 2025-12-06 20:24:30 +08:00
Fix aiofiles type definitions (#4650)
This commit is contained in:
committed by
GitHub
parent
b76d9e46b8
commit
bad9701849
19
third_party/3/aiofiles/base.pyi
vendored
19
third_party/3/aiofiles/base.pyi
vendored
@@ -1,17 +1,18 @@
|
||||
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:
|
||||
class AsyncBase(Generic[_T]):
|
||||
def __init__(self, file: str, loop: Any, executor: Any) -> None: ...
|
||||
async def __aiter__(self) -> Iterator[str]: ...
|
||||
async def __anext__(self) -> str: ...
|
||||
async def __aiter__(self) -> Iterator[_T]: ...
|
||||
async def __anext__(self) -> _T: ...
|
||||
|
||||
class AiofilesContextManager(Generic[_V_co, _T_co, _T_contra]):
|
||||
def __init__(self, __coro: Coroutine[_V_co, _T_co, _T_contra]) -> None: ...
|
||||
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] = ...
|
||||
@@ -25,10 +26,10 @@ class AiofilesContextManager(Generic[_V_co, _T_co, _T_contra]):
|
||||
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]: ...
|
||||
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: ...
|
||||
|
||||
12
third_party/3/aiofiles/threadpool/__init__.pyi
vendored
12
third_party/3/aiofiles/threadpool/__init__.pyi
vendored
@@ -2,7 +2,7 @@ from _typeshed import AnyPath, OpenBinaryMode, OpenBinaryModeReading, OpenBinary
|
||||
from typing import Any, Callable, Optional, Union, overload
|
||||
from typing_extensions import Literal
|
||||
|
||||
from ..base import AsyncBase
|
||||
from ..base import AiofilesContextManager, AsyncBase
|
||||
from .binary import AsyncBufferedIOBase, AsyncBufferedReader, AsyncFileIO
|
||||
from .text import AsyncTextIOWrapper
|
||||
|
||||
@@ -21,7 +21,7 @@ def open(
|
||||
*,
|
||||
loop: Optional[Any] = ...,
|
||||
executor: Optional[Any] = ...,
|
||||
) -> AsyncTextIOWrapper: ...
|
||||
) -> AiofilesContextManager[None, None, AsyncTextIOWrapper]: ...
|
||||
@overload
|
||||
def open(
|
||||
file: _OpenFile,
|
||||
@@ -35,7 +35,7 @@ def open(
|
||||
*,
|
||||
loop: Optional[Any] = ...,
|
||||
executor: Optional[Any] = ...,
|
||||
) -> AsyncFileIO: ...
|
||||
) -> AiofilesContextManager[None, None, AsyncFileIO]: ...
|
||||
@overload
|
||||
def open(
|
||||
file: _OpenFile,
|
||||
@@ -49,7 +49,7 @@ def open(
|
||||
*,
|
||||
loop: Optional[Any] = ...,
|
||||
executor: Optional[Any] = ...,
|
||||
) -> AsyncBufferedIOBase: ...
|
||||
) -> AiofilesContextManager[None, None, AsyncBufferedIOBase]: ...
|
||||
@overload
|
||||
def open(
|
||||
file: _OpenFile,
|
||||
@@ -63,7 +63,7 @@ def open(
|
||||
*,
|
||||
loop: Optional[Any] = ...,
|
||||
executor: Optional[Any] = ...,
|
||||
) -> AsyncBufferedReader: ...
|
||||
) -> AiofilesContextManager[None, None, AsyncBufferedReader]: ...
|
||||
@overload
|
||||
def open(
|
||||
file: _OpenFile,
|
||||
@@ -77,4 +77,4 @@ def open(
|
||||
*,
|
||||
loop: Optional[Any] = ...,
|
||||
executor: Optional[Any] = ...,
|
||||
) -> AsyncBase: ...
|
||||
) -> AiofilesContextManager[None, None, AsyncBase[bytes]]: ...
|
||||
|
||||
4
third_party/3/aiofiles/threadpool/binary.pyi
vendored
4
third_party/3/aiofiles/threadpool/binary.pyi
vendored
@@ -1,5 +1,5 @@
|
||||
from ..base import AsyncBase
|
||||
|
||||
class AsyncBufferedIOBase(AsyncBase): ...
|
||||
class AsyncBufferedIOBase(AsyncBase[bytes]): ...
|
||||
class AsyncBufferedReader(AsyncBufferedIOBase): ...
|
||||
class AsyncFileIO(AsyncBase): ...
|
||||
class AsyncFileIO(AsyncBase[bytes]): ...
|
||||
|
||||
2
third_party/3/aiofiles/threadpool/text.pyi
vendored
2
third_party/3/aiofiles/threadpool/text.pyi
vendored
@@ -1,3 +1,3 @@
|
||||
from ..base import AsyncBase
|
||||
|
||||
class AsyncTextIOWrapper(AsyncBase): ...
|
||||
class AsyncTextIOWrapper(AsyncBase[str]): ...
|
||||
|
||||
Reference in New Issue
Block a user