(self, key, value)
Changes anything not dundered or not a descriptor.

        If an enum member name is used twice, an error is raised; duplicate
        values are not checked for.

        Single underscore (sunder) names are reserved.
Changes anything not dundered or not a descriptor.
Changes anything not dundered or not a descriptor .
def __setitem__(self, key, value):
        """
        Changes anything not dundered or not a descriptor.

        If an enum member name is used twice, an error is raised; duplicate
        values are not checked for.

        Single underscore (sunder) names are reserved.
        """
        if _is_private(self._cls_name, key):
            import warnings
            warnings.warn(
                    "private variables, such as %r, will be normal attributes in 3.11"
                        % (key, ),
                    DeprecationWarning,
                    stacklevel=2,
                    )
        if _is_sunder(key):
            if key not in (
                    '_order_', '_create_pseudo_member_',
                    '_generate_next_value_', '_missing_', '_ignore_',
                    ):
                raise ValueError('_names_ are reserved for future Enum use')
            if key == '_generate_next_value_':
                # check if members already defined as auto()
                if self._auto_called:
                    raise TypeError("_generate_next_value_ must be defined before members")
                setattr(self, '_generate_next_value', value)
            elif key == '_ignore_':
                if isinstance(value, str):
                    value = value.replace(',',' ').split()
                else:
                    value = list(value)
                self._ignore = value
                already = set(value) & set(self._member_names)
                if already:
                    raise ValueError(
                            '_ignore_ cannot specify already set names: %r'
                            % (already, )
                            )
        elif _is_dunder(key):
            if key == '__order__':
                key = '_order_'
        elif key in self._member_names:
            # descriptor overwriting an enum?
            raise TypeError('Attempted to reuse key: %r' % key)
        elif key in self._ignore:
            pass
        elif not _is_descriptor(value):
            if key in self:
                # enum overwriting a descriptor?
                raise TypeError('%r already defined as: %r' % (key, self[key]))
            if isinstance(value, auto):
                if value.value == _auto_null:
                    value.value = self._generate_next_value(
                            key,
                            1,
                            len(self._member_names),
                            self._last_values[:],
                            )
                    self._auto_called = True
                value = value.value
            self._member_names.append(key)
            self._last_values.append(value)
        super().__setitem__(key, value)
def __setitem__ ( self , key , value ) : if _is_private ( self . _cls_name , key ) : import warnings warnings . warn ( "private variables, such as %r, will be normal attributes in 3.11" % ( key , ) , DeprecationWarning , stacklevel = 2 , ) if _is_sunder ( key ) : if key not in ( '_order_' , '_create_pseudo_member_' , '_generate_next_value_' , '_missing_' , '_ignore_' , ) : raise ValueError ( '_names_ are reserved for future Enum use' ) if key == '_generate_next_value_' : # check if members already defined as auto() if self . _auto_called : raise TypeError ( "_generate_next_value_ must be defined before members" ) setattr ( self , '_generate_next_value' , value ) elif key == '_ignore_' : if isinstance ( value , str ) : value = value . replace ( ',' , ' ' ) . split ( ) else : value = list ( value ) self . _ignore = value already = set ( value ) & set ( self . _member_names ) if already : raise ValueError ( '_ignore_ cannot specify already set names: %r' % ( already , ) ) elif _is_dunder ( key ) : if key == '__order__' : key = '_order_' elif key in self . _member_names : # descriptor overwriting an enum? raise TypeError ( 'Attempted to reuse key: %r' % key ) elif key in self . _ignore : pass elif not _is_descriptor ( value ) : if key in self : # enum overwriting a descriptor? raise TypeError ( '%r already defined as: %r' % ( key , self [ key ] ) ) if isinstance ( value , auto ) : if value . value == _auto_null : value . value = self . _generate_next_value ( key , 1 , len ( self . _member_names ) , self . _last_values [ : ] , ) self . _auto_called = True value = value . value self . _member_names . append ( key ) self . _last_values . append ( value ) super ( ) . __setitem__ ( key , value )