Currently typer does not support union types. See this issue, and this comment in particular:
Is there any workaround for this currently? I've got a usecase where I need to be able to accept any of bool | str | float | int in a data science CLI application. I'm taking a str and using literal_eval to cast it back to its original type. Is there a better option?
Currently typer does not support union types. See this issue, and this comment in particular:
Originally posted by @echus in https://github.com/fastapi/typer/issues/461#issuecomment-2230415249
Using
pydantic.TypeAdapter
to parse them can be implemented quite easily.