def _set(self, key, value):
    if key in self._value_map:
      existing_value = self._value_map[key]
      existing_rank = existing_value.rank
    else:
      existing_rank = RankedValue.NONE

    if isinstance(value, RankedValue):
      new_rank = value.rank
    else:
      raise AttributeError('Value must be of type RankedValue: {}'.format(value))

    if new_rank >= existing_rank:
      # We set values from outer scopes before values from inner scopes, so
      # in case of equal rank we overwrite. That way that the inner scope value wins.
      self._value_map[key] = value

  # Support natural dynamic access, e.g., opts[foo] is more idiomatic than getattr(opts, 'foo').
dataset/ETHPy150Open pantsbuild/pants/src/python/pants/option/option_value_container.py/OptionValueContainer._set/original