MCPcopy Index your code
hub / github.com/python/cpython / _ArgumentGroup

Class _ArgumentGroup

Lib/argparse.py:1831–1873  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1829
1830
1831class _ArgumentGroup(_ActionsContainer):
1832
1833 def __init__(self, container, title=None, description=None, **kwargs):
1834 if 'prefix_chars' in kwargs:
1835 import warnings
1836 depr_msg = (
1837 "The use of the undocumented 'prefix_chars' parameter in "
1838 "ArgumentParser.add_argument_group() is deprecated."
1839 )
1840 warnings.warn(depr_msg, DeprecationWarning, stacklevel=3)
1841
1842 # add any missing keyword arguments by checking the container
1843 update = kwargs.setdefault
1844 update('conflict_handler', container.conflict_handler)
1845 update('prefix_chars', container.prefix_chars)
1846 update('argument_default', container.argument_default)
1847 super_init = super(_ArgumentGroup, self).__init__
1848 super_init(description=description, **kwargs)
1849
1850 # group attributes
1851 self.title = title
1852 self._group_actions = []
1853
1854 # share most attributes with the container
1855 self._registries = container._registries
1856 self._actions = container._actions
1857 self._option_string_actions = container._option_string_actions
1858 self._defaults = container._defaults
1859 self._has_negative_number_optionals = \
1860 container._has_negative_number_optionals
1861 self._mutually_exclusive_groups = container._mutually_exclusive_groups
1862
1863 def _add_action(self, action):
1864 action = super(_ArgumentGroup, self)._add_action(action)
1865 self._group_actions.append(action)
1866 return action
1867
1868 def _remove_action(self, action):
1869 super(_ArgumentGroup, self)._remove_action(action)
1870 self._group_actions.remove(action)
1871
1872 def add_argument_group(self, *args, **kwargs):
1873 raise ValueError('argument groups cannot be nested')
1874
1875class _MutuallyExclusiveGroup(_ArgumentGroup):
1876

Callers 1

add_argument_groupMethod · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…