Skip to content

Fix aiofiles type definitions #4650

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Oct 23, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 10 additions & 9 deletions third_party/3/aiofiles/base.pyi
Original file line number Diff line number Diff line change
@@ -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] = ...
Expand All @@ -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 changes: 6 additions & 6 deletions third_party/3/aiofiles/threadpool/__init__.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -21,7 +21,7 @@ def open(
*,
loop: Optional[Any] = ...,
executor: Optional[Any] = ...,
) -> AsyncTextIOWrapper: ...
) -> AiofilesContextManager[None, None, AsyncTextIOWrapper]: ...
@overload
def open(
file: _OpenFile,
Expand All @@ -35,7 +35,7 @@ def open(
*,
loop: Optional[Any] = ...,
executor: Optional[Any] = ...,
) -> AsyncFileIO: ...
) -> AiofilesContextManager[None, None, AsyncFileIO]: ...
@overload
def open(
file: _OpenFile,
Expand All @@ -49,7 +49,7 @@ def open(
*,
loop: Optional[Any] = ...,
executor: Optional[Any] = ...,
) -> AsyncBufferedIOBase: ...
) -> AiofilesContextManager[None, None, AsyncBufferedIOBase]: ...
@overload
def open(
file: _OpenFile,
Expand All @@ -63,7 +63,7 @@ def open(
*,
loop: Optional[Any] = ...,
executor: Optional[Any] = ...,
) -> AsyncBufferedReader: ...
) -> AiofilesContextManager[None, None, AsyncBufferedReader]: ...
@overload
def open(
file: _OpenFile,
Expand All @@ -77,4 +77,4 @@ def open(
*,
loop: Optional[Any] = ...,
executor: Optional[Any] = ...,
) -> AsyncBase: ...
) -> AiofilesContextManager[None, None, AsyncBase[bytes]]: ...
4 changes: 2 additions & 2 deletions third_party/3/aiofiles/threadpool/binary.pyi
Original file line number Diff line number Diff line change
@@ -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 changes: 1 addition & 1 deletion third_party/3/aiofiles/threadpool/text.pyi
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
from ..base import AsyncBase

class AsyncTextIOWrapper(AsyncBase): ...
class AsyncTextIOWrapper(AsyncBase[str]): ...