Skip to content
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

Fix return type of workflow.wait #650

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
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
8 changes: 4 additions & 4 deletions temporalio/workflow.py
Original file line number Diff line number Diff line change
Expand Up @@ -4486,7 +4486,7 @@ async def wait(
*,
timeout: Optional[float] = None,
return_when: str = asyncio.ALL_COMPLETED,
) -> Tuple[List[asyncio.Task[AnyType]], set[asyncio.Task[AnyType]]]: ...
) -> Tuple[List[asyncio.Task[AnyType]], List[asyncio.Task[AnyType]]]: ...


async def wait(
Expand All @@ -4505,9 +4505,9 @@ async def wait(
# but the "set" is changed out for a "list" and fixed up some typing/format

if asyncio.isfuture(fs) or asyncio.iscoroutine(fs):
raise TypeError(f"expect a list of futures, not {type(fs).__name__}")
raise TypeError(f"Expect an iterable of Tasks/Futures, not {type(fs).__name__}")
if not fs:
raise ValueError("Set of Tasks/Futures is empty.")
raise ValueError("Sequence of Tasks/Futures must not be empty.")
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This check doesn't actually make sense, since the input could be an empty generator, which is truthy, but will become empty when materialized as a list below. Leaving for now since this is copied from cPython.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍 If they Python authors were better, it'd be below fs = list(fs) heh

if return_when not in (
asyncio.FIRST_COMPLETED,
asyncio.FIRST_EXCEPTION,
Expand All @@ -4534,7 +4534,7 @@ async def _wait(
# https://github.com/python/cpython/blob/v3.12.3/Lib/asyncio/tasks.py#L522
# but the "set" is changed out for a "list" and fixed up some typing/format

assert fs, "Set of Futures is empty."
assert fs, "Sequence of Tasks/Futures must not be empty."
waiter = loop.create_future()
timeout_handle = None
if timeout is not None:
Expand Down
Loading