File tree Expand file tree Collapse file tree 2 files changed +17
-0
lines changed
Expand file tree Collapse file tree 2 files changed +17
-0
lines changed Original file line number Diff line number Diff line change @@ -166,7 +166,18 @@ def __init__(
166166 indent_increment = 2 ,
167167 max_help_position = 24 ,
168168 width = None ,
169+ color = None ,
169170 ):
171+ # Handle deprecated 'color' parameter for backwards compatibility
172+ if color is not None :
173+ import warnings
174+ warnings .warn (
175+ "The 'color' parameter is deprecated. "
176+ "Set 'color' in ArgumentParser instead." ,
177+ DeprecationWarning ,
178+ stacklevel = 2 ,
179+ )
180+
170181 # default setting for width
171182 if width is None :
172183 import shutil
Original file line number Diff line number Diff line change @@ -5702,6 +5702,12 @@ def test_direct_formatter_instantiation(self):
57025702 help_text = formatter .format_help ()
57035703 self .assertEqual (help_text , "usage: program\n " )
57045704
5705+ def test_formatter_color_parameter_deprecated (self ):
5706+ with self .assertWarns (DeprecationWarning ) as cm :
5707+ argparse .HelpFormatter (prog = "program" , color = True )
5708+ self .assertIn ("'color' parameter is deprecated" , str (cm .warning ))
5709+ self .assertIn ("ArgumentParser" , str (cm .warning ))
5710+
57055711# =====================================
57065712# Optional/Positional constructor tests
57075713# =====================================
You can’t perform that action at this time.
0 commit comments