Alessandro De Rose
05/22/2023, 4:46 PMmypy is complaining when attempting to unpack a tuple returned from a task. In the example below, when attempting to unpack a & b from the call to get_numbers, mypy raises the error "None" object is not iterable. However, the type definition for the get_numbers function shows that None should never be returned from the task.
The main issue is that the type of get_numbers within the flow is Task[(a: int, b: int), tuple[int, int]], instead of tuple[int, int] as mypy is expecting. Any idea how to avoid this type error without completely ignoring it? (Prefect v2.10.10, mypy v1.3.0)
from prefect import flow, task
@task
def get_numbers(a: int, b: int) -> tuple[int, int]:
return a, b
@flow
def get_numbers_flow() -> None:
a, b = get_numbers(1, 2) # <- "None" object is not iterable.