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

Geert

01/17/2024, 11:03 AM
Hi, is it possible to have a
typing.Optional
input to a workflow?
Copy code
@workflow
def wf(foo: Optional[str]):
    ...
gives me:
Copy code
Missing option '--foo'.
k

Kevin Su

01/17/2024, 11:05 AM
yes, try
Copy code
@workflow
def wf(foo: Optional[str] = None):
    ...
g

Geert

01/17/2024, 11:06 AM
Ah sorry I simplified my example a bit too much, Iā€™m using:
Copy code
def wf(foo: Optional[list[str]] = None):
Should I use a different default?
When trying
[]
instead of `None`:
Copy code
Invalid value for '--foo': Failed to convert param <Option foo>, [] to typing.Optional[typing.List[str]]
Adding any string to the list and using that as default seems to work, not the prettiest but can progress with that šŸ™‚ :
Copy code
def wf(foo: Optional[list[str]] = [""]):
k

Kevin Su

01/17/2024, 11:18 AM
odd. might creating a issue for it. [flyte-bug]
3 Views