<#3682 [BUG] flytekit 1.6.0 task function calls do...
# flyte-github
a
#3682 [BUG] flytekit 1.6.0 task function calls do not type check Issue created by tekumara Describe the bug In flyteorg/flytekit#1631 the
task
return type was changed to effectively
Tuple[Promise] | Promise | VoidPromise | Tuple[Unknown, ...] | None
. This breaks usage of tasks in type checkers like pyright / vscode. Expected behavior Task function calls still type check correctly, as they did in flytekit 1.5.0 Additional context to reproduce This type checks without errors in flytekit 1.5.0:
Copy code
from typing import Dict, List, NamedTuple

import pandas as pd
from flytekit import task, workflow


class OpenFlightsData(NamedTuple):
    routes: List[Dict[str, str]]
    airlines: Dict[str, str]
    airports: Dict[str, Dict[str, str]]


@task()
def extract_reference_data() -> OpenFlightsData:
    return OpenFlightsData(
        routes=[{"MAO": "CIZ"}], airlines={"0B": "Blue Air"}, airports={"AAA": {"lat": "1", "lon": "2"}}
    )


@task()
def extract_live_data() -> pd.DataFrame:
    return pd.DataFrame()


@task()
def transform(raw_aircraft_data: pd.DataFrame, airlines: Dict[str, str]) -> pd.DataFrame:
    # do stuff ..
    return pd.DataFrame()


@workflow
def main() -> None:
    reference_data = extract_reference_data()
    reveal_type(reference_data)   # expecting OpenFlightsData
    live_data = extract_live_data()
    reveal_type(live_data)        # expecting Dataframe

    transform(raw_aircraft_data=live_data, airlines=reference_data.airlines)


if __name__ == "__main__":
    main()
With flytekit 1.6.0 and pyright / vscode:
Copy code
❯ pyright test.py
test.py
  test.py:34:17 - information: Type of "reference_data" is "Tuple[Promise] | Promise | VoidPromise | Tuple[Unknown, ...] | None"
  test.py:36:17 - information: Type of "live_data" is "Tuple[Promise] | Promise | VoidPromise | Tuple[Unknown, ...] | None"
  test.py:38:68 - error: Cannot access member "airlines" for type "Tuple[Promise]"
    Member "airlines" is unknown (reportGeneralTypeIssues)
  test.py:38:68 - error: Cannot access member "airlines" for type "Promise"
    Member "airlines" is unknown (reportGeneralTypeIssues)
  test.py:38:68 - error: Cannot access member "airlines" for type "VoidPromise"
    Member "airlines" is unknown (reportGeneralTypeIssues)
  test.py:38:68 - error: Cannot access member "airlines" for type "Tuple[Unknown, ...]"
    Member "airlines" is unknown (reportGeneralTypeIssues)
  test.py:38:68 - error: "airlines" is not a known member of "None" (reportOptionalMemberAccess)
5 errors, 0 warnings, 2 informations
Screenshots No response Are you sure this issue hasn't been raised already? ☑︎ Yes Have you read the Code of Conduct? ☑︎ Yes flyteorg/flyte