diff --git a/third_party/3/aiofiles/base.pyi b/third_party/3/aiofiles/base.pyi index 17ac384e8945..13c76ed7e7e1 100644 --- a/third_party/3/aiofiles/base.pyi +++ b/third_party/3/aiofiles/base.pyi @@ -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: ... diff --git a/third_party/3/aiofiles/threadpool/__init__.pyi b/third_party/3/aiofiles/threadpool/__init__.pyi index c4d8eb9d9683..840f9ce48cd2 100644 --- a/third_party/3/aiofiles/threadpool/__init__.pyi +++ b/third_party/3/aiofiles/threadpool/__init__.pyi @@ -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]]: ... diff --git a/third_party/3/aiofiles/threadpool/binary.pyi b/third_party/3/aiofiles/threadpool/binary.pyi index 909c9d2eaf05..5c51c064acbf 100644 --- a/third_party/3/aiofiles/threadpool/binary.pyi +++ b/third_party/3/aiofiles/threadpool/binary.pyi @@ -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]): ... diff --git a/third_party/3/aiofiles/threadpool/text.pyi b/third_party/3/aiofiles/threadpool/text.pyi index fcd8f2df8d3e..7662768f34e0 100644 --- a/third_party/3/aiofiles/threadpool/text.pyi +++ b/third_party/3/aiofiles/threadpool/text.pyi @@ -1,3 +1,3 @@ from ..base import AsyncBase -class AsyncTextIOWrapper(AsyncBase): ... +class AsyncTextIOWrapper(AsyncBase[str]): ...