@@ -1215,42 +1215,30 @@ def __init__(
1215
1215
behavior on this parser. If this is None or not present, then cmd2 will use
1216
1216
argparse_completer.DEFAULT_AP_COMPLETER when tab completing this parser's arguments
1217
1217
"""
1218
+ kw_args : dict [str , bool ] = {}
1218
1219
if sys .version_info >= (3 , 14 ):
1219
1220
# Python >= 3.14 so pass new arguments to parent argparse.ArgumentParser class
1220
- super ().__init__ (
1221
- prog = prog ,
1222
- usage = usage ,
1223
- description = description ,
1224
- epilog = epilog ,
1225
- parents = parents if parents else [],
1226
- formatter_class = formatter_class , # type: ignore[arg-type]
1227
- prefix_chars = prefix_chars ,
1228
- fromfile_prefix_chars = fromfile_prefix_chars ,
1229
- argument_default = argument_default ,
1230
- conflict_handler = conflict_handler ,
1231
- add_help = add_help ,
1232
- allow_abbrev = allow_abbrev ,
1233
- exit_on_error = exit_on_error , # added in Python 3.9
1234
- suggest_on_error = suggest_on_error , # added in Python 3.14
1235
- color = color , # added in Python 3.14
1236
- )
1237
- else :
1238
- # Python < 3.14, so don't pass new arguments to parent argparse.ArgumentParser class
1239
- super ().__init__ (
1240
- prog = prog ,
1241
- usage = usage ,
1242
- description = description ,
1243
- epilog = epilog ,
1244
- parents = parents if parents else [],
1245
- formatter_class = formatter_class , # type: ignore[arg-type]
1246
- prefix_chars = prefix_chars ,
1247
- fromfile_prefix_chars = fromfile_prefix_chars ,
1248
- argument_default = argument_default ,
1249
- conflict_handler = conflict_handler ,
1250
- add_help = add_help ,
1251
- allow_abbrev = allow_abbrev ,
1252
- exit_on_error = exit_on_error , # added in Python 3.9
1253
- )
1221
+ kw_args = {
1222
+ "suggest_on_error" : suggest_on_error ,
1223
+ "color" : color ,
1224
+ }
1225
+
1226
+ super ().__init__ (
1227
+ prog = prog ,
1228
+ usage = usage ,
1229
+ description = description ,
1230
+ epilog = epilog ,
1231
+ parents = parents if parents else [],
1232
+ formatter_class = formatter_class , # type: ignore[arg-type]
1233
+ prefix_chars = prefix_chars ,
1234
+ fromfile_prefix_chars = fromfile_prefix_chars ,
1235
+ argument_default = argument_default ,
1236
+ conflict_handler = conflict_handler ,
1237
+ add_help = add_help ,
1238
+ allow_abbrev = allow_abbrev ,
1239
+ exit_on_error = exit_on_error , # added in Python 3.9
1240
+ ** kw_args , # added in Python 3.14
1241
+ )
1254
1242
1255
1243
self .set_ap_completer_type (ap_completer_type ) # type: ignore[attr-defined]
1256
1244
0 commit comments