File tree Expand file tree Collapse file tree 1 file changed +4
-2
lines changed Expand file tree Collapse file tree 1 file changed +4
-2
lines changed Original file line number Diff line number Diff line change @@ -1959,11 +1959,13 @@ def add_subparsers(self, **kwargs):
19591959 # prog defaults to the usage message of this parser, skipping
19601960 # optional arguments and with no "usage:" prefix
19611961 if kwargs .get ('prog' ) is None :
1962- formatter = self ._get_formatter ()
1962+ # Create formatter without color to avoid storing ANSI codes in prog
1963+ formatter = self .formatter_class (prog = self .prog )
1964+ formatter ._set_color (False )
19631965 positionals = self ._get_positional_actions ()
19641966 groups = self ._mutually_exclusive_groups
19651967 formatter .add_usage (None , positionals , groups , '' )
1966- kwargs ['prog' ] = formatter ._decolor ( formatter . format_help ().strip () )
1968+ kwargs ['prog' ] = formatter .format_help ().strip ()
19671969
19681970 # create the parsers action and add it to the positionals list
19691971 parsers_class = self ._pop_action_class (kwargs , 'parsers' )
You can’t perform that action at this time.
0 commit comments