Skip to content

Conversation

@ferdnyc
Copy link
Contributor

@ferdnyc ferdnyc commented Feb 6, 2023

In #27808 @michiboo @abadger enhanced the display of default values in argparse help messages. Unfortunately, the docstring for argparse.ArgumentDefaultsHelpFormatter got somewhat garbled along the way.

  • Originally, commit 336bd2f added a new function, _add_defaults_to_help_string, documented as:

    Add the default value to the option help message.

    ArgumentDefaultsHelpFormatter and BooleanOptionalAction both want to add the default value to the help message when it isn't already present. This code will do that, detecting cornercases to prevent duplicates or cases where it wouldn't make sense to the end user.

  • But subsequent commit dc4babf incorporated that functionality into argparse.ArgumentDefaultsHelpFormatter._get_help_string instead, and its docstring was set to:

    Add the default value to the option help message.

    ArgumentDefaultsHelpFormatter and BooleanOptionalAction when it isn't already present. This code will do that, detecting cornercases to prevent duplicates or cases where it wouldn't make sense to the end user.

This PR clears up and simplifies removes that docstring, as it didn't really add information not discernible just by reading the code.

Signed-off-by: FeRD (Frank Dana) <ferdnyc@gmail.com>
@arhadthedev arhadthedev added the docs Documentation in the Doc dir label Feb 6, 2023
@ferdnyc
Copy link
Contributor Author

ferdnyc commented Feb 21, 2023

@michiboo Do you have a moment to look at this? It's purely a docstring adjustment, related to your previous changes to argparse's ArgumentDefaultsHelpFormatter.

@ferdnyc
Copy link
Contributor Author

ferdnyc commented Feb 21, 2023

My apologies, the PR in question was @abadger's, based on an earlier PR by @michiboo.

@abadger, do you have a moment to look at this? It's purely a docstring adjustment, related to your previous changes to argparse's ArgumentDefaultsHelpFormatter.

@serhiy-storchaka
Copy link
Member

Thank you for reporting and fixing this issue.

@ferdnyc ferdnyc deleted the argparse-formatter-docstring branch February 21, 2024 12:29
woodruffw pushed a commit to woodruffw-forks/cpython that referenced this pull request Mar 4, 2024
diegorusso pushed a commit to diegorusso/cpython that referenced this pull request Apr 17, 2024
LukasWoodtli pushed a commit to LukasWoodtli/cpython that referenced this pull request Jan 22, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

docs Documentation in the Doc dir skip issue skip news

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants