Skip to content

Commit

Permalink
Fix return annotation of Observable.__await__
Browse files Browse the repository at this point in the history
This fixes issues with mypy type checking when awaiting an observable
  • Loading branch information
giff-h authored Mar 11, 2022
1 parent 9bb8393 commit 9e37722
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions reactivex/observable/observable.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

import asyncio
import threading
from typing import Any, Callable, Iterable, Optional, TypeVar, Union, cast, overload
from typing import Any, Callable, Generator, Iterable, Optional, TypeVar, Union, cast, overload

from reactivex import abc
from reactivex.disposable import Disposable
Expand Down Expand Up @@ -254,7 +254,7 @@ def run(self) -> Any:

return run(self)

def __await__(self) -> Iterable[_T]:
def __await__(self) -> Generator[Any, None, _T]:
"""Awaits the given observable.
Returns:
Expand All @@ -263,7 +263,8 @@ def __await__(self) -> Iterable[_T]:
from ..operators._tofuture import to_future_

loop = asyncio.get_event_loop()
return iter(self.pipe(to_future_(scheduler=AsyncIOScheduler(loop=loop))))
future: asyncio.Future[_T] = self.pipe(to_future_(scheduler=AsyncIOScheduler(loop=loop)))
return future.__await__()

def __add__(self, other: Observable[_T]) -> Observable[_T]:
"""Pythonic version of :func:`concat <reactivex.concat>`.
Expand Down

0 comments on commit 9e37722

Please sign in to comment.