Skip to content

Commit

Permalink
Fix .pyi typing for asyncio
Browse files Browse the repository at this point in the history
  • Loading branch information
dkang-quora committed Nov 17, 2023
1 parent 406f29e commit 8ba658c
Showing 1 changed file with 21 additions and 7 deletions.
28 changes: 21 additions & 7 deletions asynq/decorators.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -36,16 +36,19 @@ class PureAsyncDecorator(qcore.decorators.DecoratorBase, Generic[_T]):
fn: Callable[..., _T],
task_cls: Optional[Type[futures.FutureBase]],
kwargs: Mapping[str, Any] = ...,
asyncio_fn: Optional[Callable[..., Awaitable]] = ...,
) -> None: ...
def name(self) -> str: ...
def is_pure_async_fn(self) -> bool: ...
def asyncio(self, *args, **kwargs) -> Awaitable[Any]: ...
def __call__(
self, *args: Any, **kwargs: Any
) -> Union[_T, futures.FutureBase[_T]]: ...
def __get__(self, owner: Any, cls: Any) -> PureAsyncDecorator[_T]: ... # type: ignore

class AsyncDecoratorBinder(qcore.decorators.DecoratorBinder, Generic[_T]):
def asynq(self, *args: Any, **kwargs: Any) -> async_task.AsyncTask[_T]: ...
def asyncio(self, *args, **kwargs) -> Awaitable[Any]: ...

class AsyncDecorator(PureAsyncDecorator[_T]):
binder_cls = AsyncDecoratorBinder # type: ignore
Expand All @@ -54,11 +57,10 @@ class AsyncDecorator(PureAsyncDecorator[_T]):
fn: Callable[..., _T],
cls: Optional[Type[futures.FutureBase]],
kwargs: Mapping[str, Any] = ...,
asyncio_fn: Callable[..., Awaitable] = ...,
asyncio_fn: Optional[Callable[..., Awaitable]] = ...,
): ...
def is_pure_async_fn(self) -> bool: ...
def asynq(self, *args: Any, **kwargs: Any) -> async_task.AsyncTask[_T]: ...
def asyncio(self, *args, **kwargs) -> Awaitable[Any]: ...
def __call__(self, *args: Any, **kwargs: Any) -> _T: ...
def __get__(self, owner: Any, cls: Any) -> AsyncDecorator[_T]: ... # type: ignore

Expand All @@ -77,11 +79,18 @@ class AsyncAndSyncPairDecorator(AsyncDecorator[_T]):
def __get__(self, owner: Any, cls: Any) -> Any: ...

class AsyncProxyDecorator(AsyncDecorator[_T]):
def __init__(self, fn: Callable[..., futures.FutureBase[_T]]) -> None: ...
def __init__(
self,
fn: Callable[..., futures.FutureBase[_T]],
asyncio_fn: Optional[Callable[..., Awaitable[Any]]] = ...,
) -> None: ...

class AsyncAndSyncPairProxyDecorator(AsyncProxyDecorator[_T]):
def __init__(
self, fn: Callable[..., futures.FutureBase[_T]], sync_fn: Callable[..., _T]
self,
fn: Callable[..., futures.FutureBase[_T]],
sync_fn: Callable[..., _T],
asyncio_fn: Optional[Callable[..., Awaitable[Any]]] = ...,
) -> None: ...
def __call__(self, *args: Any, **kwargs: Any) -> _T: ...

Expand All @@ -97,23 +106,28 @@ def asynq( # type: ignore
*,
sync_fn: Optional[Callable[..., Any]] = ...,
cls: Type[futures.FutureBase] = ...,
asyncio_fn: Optional[Callable[..., Awaitable]] = ...,
**kwargs: Any,
) -> _MkAsyncDecorator: ...
@overload
def asynq(
pure: bool,
sync_fn: Optional[Callable[..., Any]] = ...,
cls: Type[futures.FutureBase] = ...,
asyncio_fn: Callable[..., Awaitable] = ...,
asyncio_fn: Optional[Callable[..., Awaitable[Any]]] = ...,
**kwargs: Any,
) -> _MkPureAsyncDecorator: ... # type: ignore
@overload
def async_proxy(
*, sync_fn: Optional[Callable[..., Any]] = ...
*,
sync_fn: Optional[Callable[..., Any]] = ...,
asyncio_fn: Optional[Callable[..., Awaitable[Any]]] = ...,
) -> _MkAsyncDecorator: ...
@overload
def async_proxy(
pure: bool, sync_fn: Optional[Callable[..., Any]] = ...
pure: bool,
sync_fn: Optional[Callable[..., Any]] = ...,
asyncio_fn: Optional[Callable[..., Awaitable[Any]]] = ...,
) -> _MkPureAsyncDecorator: ...
@asynq()
def async_call(
Expand Down

0 comments on commit 8ba658c

Please sign in to comment.