-
-
Notifications
You must be signed in to change notification settings - Fork 680
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. Weโll occasionally send you account related emails.
Already on GitHub? Sign in to your account
๐๏ธ Deprecate support for is_flag
and flag_value
parameters
#987
Conversation
is_flag
and flag_value
parametersis_flag
and flag_value
parameters
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great! Looks good! ๐ Thank you! ๐
Hello ! import typer
def main(my_bool: bool = typer.Option(True, is_flag=False)):
print(f"my_bool : {my_bool}")
print(f"type(my_bool) : {type(my_bool)}")
if __name__ == "__main__":
typer.run(main) Which could be used with : > python main.py --my-bool true
my_bool : True
type(my_bool) : <class 'bool'> OR : > python main.py --my-bool false
my_bool : False
type(my_bool) : <class 'bool'> For more details, we use argo workflows to submit scripts, therefore we cannot dynamically create the --my-bool or --not-my-bool string in the argo workflow template. I also thought of using alternative names def main(my_bool: bool = typer.Option(True, "--my-bool_true/--my-bool_false")): And then : > python main.py --my-bool_true But this also becomes quite a strange use This would be wonderful if we could get this feature back ! |
Wanted to add support for @Plenitude-ai's comment. My team has the exact same use case and limitation about how bool values are dynamically created and passed as args. |
I think the original conclusion that In version When Usage: typertest.py [OPTIONS]
โญโ Options โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโฎ
โ --my-bool --no-my-bool [default: my-bool] โ
โ --help Show this message and exit. โ
โฐโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโฏ But when
Failing to pass an argument to โญโ Error โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโฎ
โ Option '--my-bool' requires an argument. โ
โฐโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโฏ |
Thanks for your reports! Let me look into this (again) and get back to you ๐ |
Fixes #986
DeprecationWarning
whenOptionInfo
receives a value foris_flag
and/orflag_value
TyperOption
doesn't useflag_value
anymore and itsis_flag
is now defined only by looking at whether or notmain_type is bool
These parameters weren't actually functional (cf. #873) and they weren't documented, so I don't think this should be breaking. But it's always difficult to say - users could be relying on unspecified internals... ๐ซค