77from argparse import Action as ArgparseAction
88from contextlib import contextmanager
99from contextvars import ContextVar
10- from typing import Any , Dict , List , Optional , Tuple , Type , Union
10+ from typing import Any , Optional , Union
1111
1212from ._common import Action , NonParsingAction , is_not_subclass_type , is_subclass , parser_context
1313from ._loaders_dumpers import get_loader_exceptions , load_value
@@ -48,8 +48,8 @@ def _is_branch_key(parser, key: str) -> bool:
4848def _find_action_and_subcommand (
4949 parser : Union [ArgumentParser , ActionsContainer ],
5050 dest : str ,
51- exclude : Optional [Union [Type [ArgparseAction ], Tuple [ Type [ArgparseAction ], ...]]] = None ,
52- ) -> Tuple [Optional [ArgparseAction ], Optional [str ]]:
51+ exclude : Optional [Union [type [ArgparseAction ], tuple [ type [ArgparseAction ], ...]]] = None ,
52+ ) -> tuple [Optional [ArgparseAction ], Optional [str ]]:
5353 """Finds an action in a parser given its destination key.
5454
5555 Args:
@@ -85,16 +85,16 @@ def _find_action_and_subcommand(
8585def _find_action (
8686 parser : Union [ArgumentParser , ActionsContainer ],
8787 dest : str ,
88- exclude : Optional [Union [Type [ArgparseAction ], Tuple [ Type [ArgparseAction ], ...]]] = None ,
88+ exclude : Optional [Union [type [ArgparseAction ], tuple [ type [ArgparseAction ], ...]]] = None ,
8989) -> Optional [ArgparseAction ]:
9090 return _find_action_and_subcommand (parser , dest , exclude = exclude )[0 ]
9191
9292
9393def _find_parent_action_and_subcommand (
9494 parser : ArgumentParser ,
9595 key : str ,
96- exclude : Optional [Union [Type [ArgparseAction ], Tuple [ Type [ArgparseAction ], ...]]] = None ,
97- ) -> Tuple [Optional [ArgparseAction ], Optional [str ]]:
96+ exclude : Optional [Union [type [ArgparseAction ], tuple [ type [ArgparseAction ], ...]]] = None ,
97+ ) -> tuple [Optional [ArgparseAction ], Optional [str ]]:
9898 action , subcommand = _find_action_and_subcommand (parser , key , exclude = exclude )
9999 if action is None and "." in key :
100100 parts = split_key (key )
@@ -108,7 +108,7 @@ def _find_parent_action_and_subcommand(
108108def _find_parent_action (
109109 parser : ArgumentParser ,
110110 key : str ,
111- exclude : Optional [Union [Type [ArgparseAction ], Tuple [ Type [ArgparseAction ], ...]]] = None ,
111+ exclude : Optional [Union [type [ArgparseAction ], tuple [ type [ArgparseAction ], ...]]] = None ,
112112) -> Optional [ArgparseAction ]:
113113 return _find_parent_action_and_subcommand (parser , key , exclude = exclude )[0 ]
114114
@@ -304,7 +304,7 @@ def is_print_config_requested(parser):
304304
305305
306306class _ActionConfigLoad (Action ):
307- def __init__ (self , basetype : Optional [Type ] = None , ** kwargs ):
307+ def __init__ (self , basetype : Optional [type ] = None , ** kwargs ):
308308 if len (kwargs ) == 0 :
309309 self ._basetype = basetype
310310 else :
@@ -344,7 +344,7 @@ def check_type(self, value, parser):
344344
345345
346346class _ActionHelpClassPath (NonParsingAction ):
347- sub_add_kwargs : Dict [str , Any ] = {}
347+ sub_add_kwargs : dict [str , Any ] = {}
348348
349349 @classmethod
350350 def get_help_types (cls , typehint ) -> Optional [tuple ]:
@@ -727,7 +727,7 @@ def get_subcommands(
727727 cfg : Namespace ,
728728 prefix : str = "" ,
729729 fail_no_subcommand : bool = True ,
730- ) -> Tuple [Optional [List [str ]], Optional [List [ArgumentParser ]]]:
730+ ) -> tuple [Optional [list [str ]], Optional [list [ArgumentParser ]]]:
731731 """Returns subcommand names and corresponding subparsers."""
732732 if parser ._subcommands_action is None :
733733 return None , None
@@ -783,7 +783,7 @@ def get_subcommand(
783783 cfg : Namespace ,
784784 prefix : str = "" ,
785785 fail_no_subcommand : bool = True ,
786- ) -> Tuple [Optional [str ], Optional [ArgumentParser ]]:
786+ ) -> tuple [Optional [str ], Optional [ArgumentParser ]]:
787787 """Returns a single subcommand name and corresponding subparser."""
788788 subcommands , subparsers = _ActionSubCommands .get_subcommands (
789789 parser ,
0 commit comments