Hi Flyte folks, does the Optional type has to be d...
# ask-the-community
j
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
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
Optional[str]
is the right way to annotate; have you been encountering any issues?
g
Python 3.10 allows str l None
s
@Eduardo Apolinario (eapolinario), is this something we can support in flytekit?
e
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
153 Views