https://prefect.io logo
#prefect-community
Title
# prefect-community
k

kiran

03/29/2023, 8:50 PM
Does anyone know how to make regular
typer
(not Prefect params) work with optional
None
? E.g., this only works when it’s not a flow:
Copy code
from typing import Optional

import typer
from prefect import flow


# @flow
def load_ids_flow(
    file_date: Optional[str] = typer.Argument(None),
) -> None:

    if file_date:
        print(f"File date is {file_date}")
    else:
        file_date = typer.prompt("What's the file date in YYYYMMDD?")
        print(f"You've entered {file_date}")

    # do something else with this file date...


if __name__ == "__main__":
    typer.run(load_ids_flow)
As a flow, I get
TypeError: Object of type 'ArgumentInfo' is not JSON serializable
Context is that I’d like to do this in case I’m running a one-off from the CLI and I forget how the script is supposed to work (it’ll prompt me with the proper info)