Skip to content

Commit 06edb94

Browse files
committed
Fix aiofiles type definitions
1 parent 228f74d commit 06edb94

File tree

4 files changed

+21
-20
lines changed

4 files changed

+21
-20
lines changed

third_party/3/aiofiles/base.pyi

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,18 @@
11
from types import CodeType, FrameType, TracebackType, coroutine
22
from typing import Any, Coroutine, Generator, Generic, Iterator, Optional, Type, TypeVar, Union
33

4+
_T = TypeVar("_T")
45
_T_co = TypeVar("_T_co", covariant=True)
56
_V_co = TypeVar("_V_co", covariant=True)
67
_T_contra = TypeVar("_T_contra", contravariant=True)
78

8-
class AsyncBase:
9+
class AsyncBase(Generic[_T]):
910
def __init__(self, file: str, loop: Any, executor: Any) -> None: ...
10-
async def __aiter__(self) -> Iterator[str]: ...
11-
async def __anext__(self) -> str: ...
11+
async def __aiter__(self) -> Iterator[_T]: ...
12+
async def __anext__(self) -> _T: ...
1213

13-
class AiofilesContextManager(Generic[_V_co, _T_co, _T_contra]):
14-
def __init__(self, __coro: Coroutine[_V_co, _T_co, _T_contra]) -> None: ...
14+
class AiofilesContextManager(Generic[_T_co, _T_contra, _V_co]):
15+
def __init__(self, __coro: Coroutine[_T_co, _T_contra, _V_co]) -> None: ...
1516
def send(self, __value: _T_contra) -> _T_co: ...
1617
def throw(
1718
self, __typ: Type[BaseException], __val: Union[BaseException, object] = ..., tb: Optional[TracebackType] = ...
@@ -25,10 +26,10 @@ class AiofilesContextManager(Generic[_V_co, _T_co, _T_contra]):
2526
def gi_code(self) -> CodeType: ...
2627
def __next__(self) -> _T_co: ...
2728
@coroutine
28-
def __iter__(self) -> Iterator[Coroutine[_V_co, _T_co, _T_contra]]: ...
29-
def __await__(self) -> Generator[Any, None, _T_co]: ...
30-
async def __anext__(self) -> Coroutine[_V_co, _T_co, _T_contra]: ...
31-
async def __aenter__(self) -> Coroutine[_V_co, _T_co, _T_contra]: ...
29+
def __iter__(self) -> Iterator[Coroutine[_T_co, _T_contra, _V_co]]: ...
30+
def __await__(self) -> Generator[Any, None, _V_co]: ...
31+
async def __anext__(self) -> _V_co: ...
32+
async def __aenter__(self) -> _V_co: ...
3233
async def __aexit__(
3334
self, exc_type: Optional[Type[BaseException]], exc_val: Optional[BaseException], exc_tb: Optional[TracebackType]
3435
) -> None: ...

third_party/3/aiofiles/threadpool/__init__.pyi

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
from _typeshed import AnyPath, OpenBinaryMode, OpenBinaryModeReading, OpenBinaryModeUpdating, OpenBinaryModeWriting, OpenTextMode
2-
from typing import Any, Callable, Optional, Union, overload
2+
from typing import Any, Callable, Coroutine, Optional, Union, overload
33
from typing_extensions import Literal
44

5-
from ..base import AsyncBase
5+
from ..base import AsyncBase, AiofilesContextManager
66
from .binary import AsyncBufferedIOBase, AsyncBufferedReader, AsyncFileIO
77
from .text import AsyncTextIOWrapper
88

@@ -21,7 +21,7 @@ def open(
2121
*,
2222
loop: Optional[Any] = ...,
2323
executor: Optional[Any] = ...,
24-
) -> AsyncTextIOWrapper: ...
24+
) -> AiofilesContextManager[Coroutine[None, None, AsyncTextIOWrapper]]: ...
2525
@overload
2626
def open(
2727
file: _OpenFile,
@@ -35,7 +35,7 @@ def open(
3535
*,
3636
loop: Optional[Any] = ...,
3737
executor: Optional[Any] = ...,
38-
) -> AsyncFileIO: ...
38+
) -> AiofilesContextManager[Coroutine[None, None, AsyncFileIO]]: ...
3939
@overload
4040
def open(
4141
file: _OpenFile,
@@ -49,7 +49,7 @@ def open(
4949
*,
5050
loop: Optional[Any] = ...,
5151
executor: Optional[Any] = ...,
52-
) -> AsyncBufferedIOBase: ...
52+
) -> AiofilesContextManager[Coroutine[None, None, AsyncBufferedIOBase]]: ...
5353
@overload
5454
def open(
5555
file: _OpenFile,
@@ -63,7 +63,7 @@ def open(
6363
*,
6464
loop: Optional[Any] = ...,
6565
executor: Optional[Any] = ...,
66-
) -> AsyncBufferedReader: ...
66+
) -> AiofilesContextManager[Coroutine[None, None, AsyncBufferedReader]]: ...
6767
@overload
6868
def open(
6969
file: _OpenFile,
@@ -77,4 +77,4 @@ def open(
7777
*,
7878
loop: Optional[Any] = ...,
7979
executor: Optional[Any] = ...,
80-
) -> AsyncBase: ...
80+
) -> AiofilesContextManager[Coroutine[None, None, AsyncBase[bytes]]]: ...
Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
from ..base import AsyncBase
22

3-
class AsyncBufferedIOBase(AsyncBase): ...
4-
class AsyncBufferedReader(AsyncBufferedIOBase): ...
5-
class AsyncFileIO(AsyncBase): ...
3+
class AsyncBufferedIOBase(AsyncBase[bytes]): ...
4+
class AsyncBufferedReader(AsyncBufferedIOBase[bytes]): ...
5+
class AsyncFileIO(AsyncBase[bytes]): ...
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
from ..base import AsyncBase
22

3-
class AsyncTextIOWrapper(AsyncBase): ...
3+
class AsyncTextIOWrapper(AsyncBase[str]): ...

0 commit comments

Comments
 (0)