• Greg Gydush

    Greg Gydush

    2 months ago
    Anyone using latest
    mypy
    and have this issue with
    NamedTuple
    (for named outputs). The example in the docs (shown below) fails mypy 0.910 Code from Flyte docs:
    import typing
    
    from flytekit import task
    
    hello_output = typing.NamedTuple("OP", greet=str)
    
    
    @task
    def say_hello() -> hello_output:
        return hello_output("hello world")
    Error:
    mint/workflows/tmp.py:5:16: error: Unexpected arguments to namedtuple()  [misc]
        hello_output = typing.NamedTuple("OP", greet=str)
                       ^
    mint/workflows/tmp.py: note: In function "say_hello":
    mint/workflows/tmp.py:10:12: error: Too many arguments for "hello_output"  [call-arg]
            return hello_output("hello world")
                   ^
  • Is solution here to just
    type: ignore
    for now and we can bring this up to the
    mypy
    people?
  • Samhita Alla

    Samhita Alla

    2 months ago
    Hi @Greg Gydush!
    hello_output = typing.NamedTuple("hello_output", [("greet", str)])
    works. @Yee, should we modify all the NamedTuple examples in the docs to keep them in sync with mypy?