6767__all__ = [
6868 'ArgumentParser' ,
6969 'ArgumentError' ,
70+ 'ArgumentGroup' ,
7071 'ArgumentTypeError' ,
7172 'BooleanOptionalAction' ,
7273 'FileType' ,
7576 'RawDescriptionHelpFormatter' ,
7677 'RawTextHelpFormatter' ,
7778 'MetavarTypeHelpFormatter' ,
79+ 'MutuallyExclusiveGroup' ,
7880 'Namespace' ,
7981 'Action' ,
8082 'ONE_OR_MORE' ,
@@ -1699,12 +1701,12 @@ def add_argument(self, *args, **kwargs):
16991701 return self ._add_action (action )
17001702
17011703 def add_argument_group (self , * args , ** kwargs ):
1702- group = _ArgumentGroup (self , * args , ** kwargs )
1704+ group = ArgumentGroup (self , * args , ** kwargs )
17031705 self ._action_groups .append (group )
17041706 return group
17051707
17061708 def add_mutually_exclusive_group (self , ** kwargs ):
1707- group = _MutuallyExclusiveGroup (self , ** kwargs )
1709+ group = MutuallyExclusiveGroup (self , ** kwargs )
17081710 self ._mutually_exclusive_groups .append (group )
17091711 return group
17101712
@@ -1892,7 +1894,7 @@ def _check_help(self, action):
18921894 raise ValueError ('badly formed help string' ) from exc
18931895
18941896
1895- class _ArgumentGroup (_ActionsContainer ):
1897+ class ArgumentGroup (_ActionsContainer ):
18961898
18971899 def __init__ (self , container , title = None , description = None , ** kwargs ):
18981900 if 'prefix_chars' in kwargs :
@@ -1907,7 +1909,7 @@ def __init__(self, container, title=None, description=None, **kwargs):
19071909 update ('conflict_handler' , container .conflict_handler )
19081910 update ('prefix_chars' , container .prefix_chars )
19091911 update ('argument_default' , container .argument_default )
1910- super_init = super (_ArgumentGroup , self ).__init__
1912+ super_init = super (ArgumentGroup , self ).__init__
19111913 super_init (description = description , ** kwargs )
19121914
19131915 # group attributes
@@ -1924,21 +1926,21 @@ def __init__(self, container, title=None, description=None, **kwargs):
19241926 self ._mutually_exclusive_groups = container ._mutually_exclusive_groups
19251927
19261928 def _add_action (self , action ):
1927- action = super (_ArgumentGroup , self )._add_action (action )
1929+ action = super (ArgumentGroup , self )._add_action (action )
19281930 self ._group_actions .append (action )
19291931 return action
19301932
19311933 def _remove_action (self , action ):
1932- super (_ArgumentGroup , self )._remove_action (action )
1934+ super (ArgumentGroup , self )._remove_action (action )
19331935 self ._group_actions .remove (action )
19341936
19351937 def add_argument_group (self , * args , ** kwargs ):
19361938 raise ValueError ('argument groups cannot be nested' )
19371939
1938- class _MutuallyExclusiveGroup ( _ArgumentGroup ):
1940+ class MutuallyExclusiveGroup ( ArgumentGroup ):
19391941
19401942 def __init__ (self , container , required = False ):
1941- super (_MutuallyExclusiveGroup , self ).__init__ (container )
1943+ super (MutuallyExclusiveGroup , self ).__init__ (container )
19421944 self .required = required
19431945 self ._container = container
19441946
@@ -1957,6 +1959,10 @@ def _remove_action(self, action):
19571959 def add_mutually_exclusive_group (self , ** kwargs ):
19581960 raise ValueError ('mutually exclusive groups cannot be nested' )
19591961
1962+ # Kept for code that imports the pre-3.16 private names.
1963+ _ArgumentGroup = ArgumentGroup
1964+ _MutuallyExclusiveGroup = MutuallyExclusiveGroup
1965+
19601966def _prog_name (prog = None ):
19611967 if prog is not None :
19621968 return prog
0 commit comments