def register(self, *args, **kwargs):
    """Register an option."""
    if self._frozen:
      raise FrozenRegistration(self.scope, args[0])

    # Prevent further registration in enclosing scopes.
    ancestor = self._parent_parser
    while ancestor:
      ancestor._freeze()
      ancestor = ancestor._parent_parser

    def check_deprecated_types(kwarg_name):
      t = kwargs.get(kwarg_name)
      # First check for deprecated direct use of the internal types.
      if t == list_option:
        deprecated_conditional(lambda: True, '0.0.83', 'list_option',
                               'Use type=list for option {} in scope {}.'.format(args[0],
                                                                                 self.scope))
      elif t == dict_option:
        deprecated_conditional(lambda: True, '0.0.83', 'dict_option',
                               'Use type=dict for option {} in scope {}.'.format(args[0],
                                                                                 self.scope))

    check_deprecated_types('type')
    check_deprecated_types('member_type')

    action = kwargs.get('action')
    # Temporary munging to effectively turn type=list options into list options,
    # for uniform handling.  From here on, type=list is an error.
    # TODO: Remove after type=list deprecation.
    if action == 'append':
      if 'type' in kwargs:
        kwargs['member_type'] = kwargs['type']
      kwargs['type'] = list
      del kwargs['action']
      deprecated_conditional(lambda: True, '0.0.83', "action='append'",
                             'Use type=list for option {} in scope {}.'.format(args[0], self.scope))

    # Temporary munging to effectively turn type='target_list_option' options into list options,
    # with member type 'target_option', for uniform handling.
    # TODO: Remove after target_list_option deprecation.
    if kwargs.get('type') == target_list_option:
      kwargs['type'] = list
      kwargs['member_type'] = target_option
      deprecated_conditional(lambda: True, '0.0.83', 'target_list_option',
                             'Use type=list, member_type=target_option '
                             'for option {} in scope {}.'.format(args[0], self.scope))

    # Temporary munging to effectively turn action='store_true' into bool-typed options.
    # From here on, action='store_true' is an error.  Ditto for store_false.
    # TODO: Remove after action='store_true'/'store_false' deprecation.
    if action == 'store_true':
      kwargs['type'] = bool
      kwargs['implicit_value'] = True
      del kwargs['action']
      deprecated_conditional(lambda: True, '0.0.83', "action='store_true'",
                             'Use type=bool for option {} in scope {}.'.format(args[0], self.scope))
    elif action == 'store_false':
      kwargs['type'] = bool
      kwargs['implicit_value'] = False
      del kwargs['action']
      deprecated_conditional(lambda: True, '0.0.83', "action='store_false'",
                             'Use type=bool, implicit_value=False '
                             'for option {} in scope {}.'.format(args[0], self.scope))

    # Boolean options always have an implicit boolean-typed default.  They can never be None.
    # We make that default explicit here.
    if kwargs.get('type') == bool and kwargs.get('default') is None:
      kwargs['default'] = not self._ensure_bool(kwargs.get('implicit_value', True))

    # Record the args. We'll do the underlying parsing on-demand.
    self._option_registrations.append((args, kwargs))
    if self._parent_parser:
      for arg in args:
        existing_scope = self._parent_parser._existing_scope(arg)
        if existing_scope is not None:
          raise Shadowing(self.scope, arg, outer_scope=self._scope_str(existing_scope))
    for arg in args:
      if arg in self._known_args:
        raise OptionAlreadyRegistered(self.scope, arg)
    self._known_args.update(args)
dataset/ETHPy150Open pantsbuild/pants/src/python/pants/option/parser.py/Parser.register/original