https://flyte.org logo
#ask-the-community
Title
# ask-the-community
j

Jay Ganbat

05/23/2023, 5:53 PM
Hi Flyte folks, does the Optional type has to be defined like this
Copy code
@task
def hello(username: Optional[str]) -> str:
because i tried to define like this
Copy code
@task
def hello(username: str | None) -> str:
but getting
Failed with Unknown Exception <class 'AssertionError'> Reason: Failed to Bind variable username for function sandbox.subworkflow.hello.
first one works though
g

Greg Gydush

05/23/2023, 6:16 PM
I've also seen this same thing 😢
have been having to import from typing for all Flyte stuff and it hurts my eyes (joking, it's totally fine)
s

Samhita Alla

05/24/2023, 4:51 AM
Optional[str]
is the right way to annotate; have you been encountering any issues?
g

Greg Gydush

05/24/2023, 5:10 AM
Python 3.10 allows str l None
s

Samhita Alla

05/24/2023, 5:18 AM
@Eduardo Apolinario (eapolinario), is this something we can support in flytekit?
e

Eduardo Apolinario (eapolinario)

05/24/2023, 5:37 PM
as Greg said, this is a python 3.10 feature described in https://peps.python.org/pep-0604/. We'll have to investigate how to handle this version-specific typing info. It might be doable. Can you create a ticket to track this investigation?
s

Samhita Alla

05/25/2023, 5:29 AM
3 Views