@@ -250,15 +250,11 @@ def my_completer(self, text, line, begidx, endidx, arg_tokens)
250250 TYPE_CHECKING ,
251251 Any ,
252252 Callable ,
253- Dict ,
254253 Iterable ,
255- List ,
256254 NoReturn ,
257255 Optional ,
258256 Protocol ,
259257 Sequence ,
260- Set ,
261- Tuple ,
262258 Type ,
263259 Union ,
264260 cast ,
@@ -350,7 +346,7 @@ class ChoicesProviderFuncBase(Protocol):
350346 Function that returns a list of choices in support of tab completion
351347 """
352348
353- def __call__ (self ) -> List [str ]: ... # pragma: no cover
349+ def __call__ (self ) -> list [str ]: ... # pragma: no cover
354350
355351
356352@runtime_checkable
@@ -359,7 +355,7 @@ class ChoicesProviderFuncWithTokens(Protocol):
359355 Function that returns a list of choices in support of tab completion and accepts a dictionary of prior arguments.
360356 """
361357
362- def __call__ (self , * , arg_tokens : Dict [str , List [str ]] = {}) -> List [str ]: ... # pragma: no cover
358+ def __call__ (self , * , arg_tokens : dict [str , list [str ]] = {}) -> list [str ]: ... # pragma: no cover
363359
364360
365361ChoicesProviderFunc = Union [ChoicesProviderFuncBase , ChoicesProviderFuncWithTokens ]
@@ -377,7 +373,7 @@ def __call__(
377373 line : str ,
378374 begidx : int ,
379375 endidx : int ,
380- ) -> List [str ]: ... # pragma: no cover
376+ ) -> list [str ]: ... # pragma: no cover
381377
382378
383379@runtime_checkable
@@ -394,8 +390,8 @@ def __call__(
394390 begidx : int ,
395391 endidx : int ,
396392 * ,
397- arg_tokens : Dict [str , List [str ]] = {},
398- ) -> List [str ]: ... # pragma: no cover
393+ arg_tokens : dict [str , list [str ]] = {},
394+ ) -> list [str ]: ... # pragma: no cover
399395
400396
401397CompleterFunc = Union [CompleterFuncBase , CompleterFuncWithTokens ]
@@ -598,7 +594,7 @@ def _action_set_descriptive_header(self: argparse.Action, descriptive_header: Op
598594############################################################################################################
599595# Patch argparse.Action with accessors for nargs_range attribute
600596############################################################################################################
601- def _action_get_nargs_range (self : argparse .Action ) -> Optional [Tuple [int , Union [int , float ]]]:
597+ def _action_get_nargs_range (self : argparse .Action ) -> Optional [tuple [int , Union [int , float ]]]:
602598 """
603599 Get the nargs_range attribute of an argparse Action.
604600
@@ -609,13 +605,13 @@ def _action_get_nargs_range(self: argparse.Action) -> Optional[Tuple[int, Union[
609605 :param self: argparse Action being queried
610606 :return: The value of nargs_range or None if attribute does not exist
611607 """
612- return cast (Optional [Tuple [int , Union [int , float ]]], getattr (self , ATTR_NARGS_RANGE , None ))
608+ return cast (Optional [tuple [int , Union [int , float ]]], getattr (self , ATTR_NARGS_RANGE , None ))
613609
614610
615611setattr (argparse .Action , 'get_nargs_range' , _action_get_nargs_range )
616612
617613
618- def _action_set_nargs_range (self : argparse .Action , nargs_range : Optional [Tuple [int , Union [int , float ]]]) -> None :
614+ def _action_set_nargs_range (self : argparse .Action , nargs_range : Optional [tuple [int , Union [int , float ]]]) -> None :
619615 """
620616 Set the nargs_range attribute of an argparse Action.
621617
@@ -673,7 +669,7 @@ def _action_set_suppress_tab_hint(self: argparse.Action, suppress_tab_hint: bool
673669# Allow developers to add custom action attributes
674670############################################################################################################
675671
676- CUSTOM_ACTION_ATTRIBS : Set [str ] = set ()
672+ CUSTOM_ACTION_ATTRIBS : set [str ] = set ()
677673_CUSTOM_ATTRIB_PFX = '_attr_'
678674
679675
@@ -746,7 +742,7 @@ def _action_set_custom_parameter(self: argparse.Action, value: Any) -> None:
746742def _add_argument_wrapper (
747743 self : argparse ._ActionsContainer ,
748744 * args : Any ,
749- nargs : Union [int , str , Tuple [int ], Tuple [int , int ], Tuple [int , float ], None ] = None ,
745+ nargs : Union [int , str , tuple [int ], tuple [int , int ], tuple [int , float ], None ] = None ,
750746 choices_provider : Optional [ChoicesProviderFunc ] = None ,
751747 completer : Optional [CompleterFunc ] = None ,
752748 suppress_tab_hint : bool = False ,
@@ -797,7 +793,7 @@ def _add_argument_wrapper(
797793 nargs_range = None
798794
799795 if nargs is not None :
800- nargs_adjusted : Union [int , str , Tuple [int ], Tuple [int , int ], Tuple [int , float ], None ]
796+ nargs_adjusted : Union [int , str , tuple [int ], tuple [int , int ], tuple [int , float ], None ]
801797 # Check if nargs was given as a range
802798 if isinstance (nargs , tuple ):
803799 # Handle 1-item tuple by setting max to INFINITY
@@ -847,7 +843,7 @@ def _add_argument_wrapper(
847843 kwargs ['nargs' ] = nargs_adjusted
848844
849845 # Extract registered custom keyword arguments
850- custom_attribs : Dict [str , Any ] = {}
846+ custom_attribs : dict [str , Any ] = {}
851847 for keyword , value in kwargs .items ():
852848 if keyword in CUSTOM_ACTION_ATTRIBS :
853849 custom_attribs [keyword ] = value
@@ -1124,9 +1120,9 @@ def _format_usage(
11241120 # End cmd2 customization
11251121
11261122 # helper for wrapping lines
1127- def get_lines (parts : List [str ], indent : str , prefix : Optional [str ] = None ) -> List [str ]:
1128- lines : List [str ] = []
1129- line : List [str ] = []
1123+ def get_lines (parts : list [str ], indent : str , prefix : Optional [str ] = None ) -> list [str ]:
1124+ lines : list [str ] = []
1125+ line : list [str ] = []
11301126 if prefix is not None :
11311127 line_len = len (prefix ) - 1
11321128 else :
@@ -1188,7 +1184,7 @@ def _format_action_invocation(self, action: argparse.Action) -> str:
11881184 return metavar
11891185
11901186 else :
1191- parts : List [str ] = []
1187+ parts : list [str ] = []
11921188
11931189 # if the Optional doesn't take a value, format is:
11941190 # -s, --long
@@ -1209,8 +1205,8 @@ def _format_action_invocation(self, action: argparse.Action) -> str:
12091205 def _determine_metavar (
12101206 self ,
12111207 action : argparse .Action ,
1212- default_metavar : Union [str , Tuple [str , ...]],
1213- ) -> Union [str , Tuple [str , ...]]:
1208+ default_metavar : Union [str , tuple [str , ...]],
1209+ ) -> Union [str , tuple [str , ...]]:
12141210 """Custom method to determine what to use as the metavar value of an action"""
12151211 if action .metavar is not None :
12161212 result = action .metavar
@@ -1226,19 +1222,19 @@ def _determine_metavar(
12261222 def _metavar_formatter (
12271223 self ,
12281224 action : argparse .Action ,
1229- default_metavar : Union [str , Tuple [str , ...]],
1230- ) -> Callable [[int ], Tuple [str , ...]]:
1225+ default_metavar : Union [str , tuple [str , ...]],
1226+ ) -> Callable [[int ], tuple [str , ...]]:
12311227 metavar = self ._determine_metavar (action , default_metavar )
12321228
1233- def format (tuple_size : int ) -> Tuple [str , ...]:
1229+ def format (tuple_size : int ) -> tuple [str , ...]:
12341230 if isinstance (metavar , tuple ):
12351231 return metavar
12361232 else :
12371233 return (metavar ,) * tuple_size
12381234
12391235 return format
12401236
1241- def _format_args (self , action : argparse .Action , default_metavar : Union [str , Tuple [str , ...]]) -> str :
1237+ def _format_args (self , action : argparse .Action , default_metavar : Union [str , tuple [str , ...]]) -> str :
12421238 """Customized to handle ranged nargs and make other output less verbose"""
12431239 metavar = self ._determine_metavar (action , default_metavar )
12441240 metavar_formatter = self ._metavar_formatter (action , default_metavar )
0 commit comments