Skip to content

Commit

Permalink
Type hinted maybe_wait_for return (#143)
Browse files Browse the repository at this point in the history
  • Loading branch information
jamesbraza authored Dec 6, 2024
1 parent 02dc2e2 commit 4c2bc26
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions src/aviary/env.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
from abc import ABC, abstractmethod
from collections.abc import Awaitable, Iterator
from copy import deepcopy
from typing import Annotated, Any, Generic, Self, TypeAlias, TypeVar, cast
from typing import Annotated, Generic, Self, TypeAlias, TypeVar, cast

from pydantic import (
BaseModel,
Expand Down Expand Up @@ -39,7 +39,10 @@
Serializable: TypeAlias = dict | list | int | float | str | bool | BaseModel


async def maybe_wait_for(future: Awaitable, timeout: float | None) -> Any:
_T = TypeVar("_T")


async def maybe_wait_for(future: Awaitable[_T], timeout: float | None) -> _T:
"""Apply a timeout to an awaitable if one is provided, otherwise await indefinitely."""
if timeout is None:
return await future
Expand Down

0 comments on commit 4c2bc26

Please sign in to comment.