@@ -153,26 +153,6 @@ def _copy_items(items):
153
153
# Formatting Help
154
154
# ===============
155
155
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
-
176
156
177
157
class HelpFormatter (object ):
178
158
"""Formatter for generating usage messages and argument help strings.
@@ -716,7 +696,25 @@ class ArgumentDefaultsHelpFormatter(HelpFormatter):
716
696
"""
717
697
718
698
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
+
720
718
721
719
722
720
class MetavarTypeHelpFormatter (HelpFormatter ):
@@ -907,8 +905,6 @@ def __init__(self,
907
905
help = help ,
908
906
metavar = metavar )
909
907
910
- self .help = _add_default_to_help_string (self )
911
-
912
908
913
909
def __call__ (self , parser , namespace , values , option_string = None ):
914
910
if option_string in self .option_strings :
0 commit comments