-
-
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
Add callable support to show_default
#355
Conversation
Has anyone looked at this yet? Having to add "# type: ignore[arg-type]" everytime I use show_default with a string in an option is getting annoying |
Note this not only fixes the type hint for |
This conflicts with the refactor of defaults for |
[maintenance note] I'd suggest reviewing #501 first and then updating this PR to review the added feature. |
Adds callable support to
show_default
, allowing aCallable[[], Union[bool, str]]
to be passed to dynamically determine the default to show in help messages. Closes #354.Previously,
show_default
was incorrectly typed as justbool
instead ofUnion[bool, str]
onOption
/OptionType
. This fixes those type annotations. Closes #158.Additionally, the default string for dynamic options was defined as
default_string = _("(dynamic)")
which appears to be a bug and is confusing syntax if valid. This was simplified to match the line from arguments.I've also removed the formatted parenthesis from the displayed
show_default
value, as this value should be able to match the style of a real default. This is the only "breaking" change here.I'll happily extend documentation / tests if you're willing to accept this.