Option optional value doesn't work because is_flag is not passed to click properly
#873
-
First Check
Commit to Help
Example Codeimport typer
def main(
foo: str = typer.Option(is_flag=False, flag_value="flag", default="default"),
):
print(f"Hello {foo}")
if __name__ == "__main__":
typer.run(main)DescriptionClick support options with optional values. I'd expect Typer to work the same way, because it expose both I would expect this: But this is what I get: It works nice with #872. Operating SystemmacOS Operating System DetailsNo response Typer Version0.12.3 Python VersionPython 3.11.9 Additional ContextNo response |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 1 reply
-
|
Thanks for pointing this out! I realized it doesn't make sense to have that parameter when it's not really supported in Typer. And I consider it's better to have only the Removing the parameter was done here: #987 |
Beta Was this translation helpful? Give feedback.
-
|
Heavens, please show an example of how to use your approach and not the I need to handle --my_arg whose default is 'hello': app
# my_arg is None or False
app --my_arg
# my_arg = hello
app --my_arg bye
# my_arg = bye |
Beta Was this translation helpful? Give feedback.
Thanks for pointing this out! I realized it doesn't make sense to have that parameter when it's not really supported in Typer. And I consider it's better to have only the
boottype annotation, and if the application code needs a string, then it can check if theboolisTrueorFalse, instead of having it as part of the library.Removing the parameter was done here: #987