Skip to content

types

is_future(obj)

Checks if an object is a future narrowing the type.

Parameters:

Name Type Description Default
obj Future[T]

Object to check

required

Returns:

Type Description
TypeGuard[Future[T]]

TypeGuard[Future[T]]: True if it is a future

Source code in src/distilabel/utils/types.py
def is_future(obj: Union[Future[T], Any]) -> TypeGuard[Future[T]]:
    """Checks if an object is a future narrowing the type.

    Args:
        obj (Future[T]): Object to check

    Returns:
        TypeGuard[Future[T]]: True if it is a future
    """
    return isinstance(obj, Future)