@@ -153,26 +153,6 @@ def _copy_items(items):
153153# Formatting Help
154154# ===============
155155
156- def _add_default_to_help_string (action ):
157- """
158- Add the default value to the option help message.
159-
160- ArgumentDefaultsHelpFormatter and BooleanOptionalAction both want to add
161- the default value to the help message when it isn't already present. This
162- code will do that, detecting cornercases to prevent duplicates or cases
163- where it wouldn't make sense to the end user.
164- """
165- help = action .help
166- if help is None :
167- help = ''
168-
169- if '%(default)' not in help :
170- if action .default is not SUPPRESS :
171- defaulting_nargs = [OPTIONAL , ZERO_OR_MORE ]
172- if action .option_strings or action .nargs in defaulting_nargs :
173- help += ' (default: %(default)s)'
174- return help
175-
176156
177157class HelpFormatter (object ):
178158 """Formatter for generating usage messages and argument help strings.
@@ -716,7 +696,25 @@ class ArgumentDefaultsHelpFormatter(HelpFormatter):
716696 """
717697
718698 def _get_help_string (self , action):
719- return _add_default_to_help_string (action )
699+ """
700+ Add the default value to the option help message.
701+
702+ ArgumentDefaultsHelpFormatter and BooleanOptionalAction when it isn't
703+ already present. This code will do that, detecting cornercases to
704+ prevent duplicates or cases where it wouldn't make sense to the end
705+ user.
706+ """
707+ help = action .help
708+ if help is None :
709+ help = ''
710+
711+ if '%(default)' not in help :
712+ if action .default is not SUPPRESS :
713+ defaulting_nargs = [OPTIONAL , ZERO_OR_MORE ]
714+ if action .option_strings or action .nargs in defaulting_nargs :
715+ help += ' (default: %(default)s)'
716+ return help
717+
720718
721719
722720class MetavarTypeHelpFormatter (HelpFormatter ):
@@ -907,8 +905,6 @@ def __init__(self,
907905 help = help ,
908906 metavar = metavar )
909907
910- self .help = _add_default_to_help_string (self )
911-
912908
913909 def __call__ (self , parser , namespace , values , option_string = None ):
914910 if option_string in self .option_strings :
0 commit comments