Skip to content
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

Minor: Pretty formatting of default values #84

Closed
baolsen opened this issue Aug 8, 2023 · 1 comment · Fixed by #98
Closed

Minor: Pretty formatting of default values #84

baolsen opened this issue Aug 8, 2023 · 1 comment · Fixed by #98
Labels
argparse Concerns argparse enhancement New feature or request

Comments

@baolsen
Copy link

baolsen commented Aug 8, 2023

Awesome plugin.

When using formatter_class=ArgumentDefaultsRichHelpFormatter

Currently the default values display fine but it would be nice to pretty-print them if possible.
Example of current:
image

I don't mind attempting a PR for it.

@hamdanal
Copy link
Owner

I agree, while in the other formatters you can use console markup to add special styles for defaults, this is not currently possible with ArgumentDefaultsRichHelpFormatter. I am not clear how to best handle this yet.
There are multiple options for where this should go:

  1. If only for the ArgumentDefaultsRichHelpFormatter formatter: we need to override its _get_help_string method
  2. If for all formatters: this then has to go in the _rich_expand_help method

There is also the question about what needs to be considered for styling:

  1. Only the default value: "foo bar (default: [argparse.defaults]%(default)s[/argparse.defaults])"
  2. The default and the surrounding parenthesis: "foo bar[argparse.defaults](default: %(default)s)[argparse.defaults]". This may not always work if the user doesn't stick to the (default: %(default)s) format. I lean toward option 1 here.

@hamdanal hamdanal added enhancement New feature or request help wanted Extra attention is needed labels Aug 10, 2023
@hamdanal hamdanal added the argparse Concerns argparse label Aug 19, 2023
hamdanal added a commit that referenced this issue Oct 7, 2023
@hamdanal hamdanal removed the help wanted Extra attention is needed label Oct 7, 2023
hamdanal added a commit that referenced this issue Oct 7, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
argparse Concerns argparse enhancement New feature or request
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants