def __call__(cls, value, *args, **kwargs):
        """Cast the value to this enum type.

        When given an integer constant, it returns the corresponding enum value, like a standard
        Python enumeration.

        When given a :ref:`value-like <lang-valuelike>`, it is cast to a value, then wrapped
        in the ``view_class`` specified for this enum type (:class:`EnumView` for :class:`Enum`,
        :class:`FlagView` for :class:`Flag`, or a custom user-defined class). If the type has no
        ``view_class`` (like :class:`IntEnum` or :class:`IntFlag`), a plain
        :class:`Value` is returned.

        Returns
        -------
        instance of itself
            For integer values, or instances of itself.
        :class:`EnumView` or its subclass
            For value-castables, as defined by the ``view_class`` keyword argument.
        :class:`Value`
            For value-castables, when a view class is not specified for this enum.
        """
        if isinstance(value, (Value, ValueCastable)):
            value = Value.cast(value)
            if cls._amaranth_view_class_ is None:
                return value
            else:
                return cls._amaranth_view_class_(cls, value)
        return super().__call__(value, *args, **kwargs)
Cast the value to this enum type.

        When given an integer constant, it returns the corresponding enum value, like a standard
        Python enumeration.

        When given a :ref:`value-like <lang-valuelike>`, it is cast to a value, then wrapped
        in the ``view_class`` specified for this enum type (:class:`EnumView` for :class:`Enum`,
        :class:`FlagView` for :class:`Flag`, or a custom user-defined class). If the type has no
        ``view_class`` (like :class:`IntEnum` or :class:`IntFlag`), a plain
        :class:`Value` is returned.

        Returns
        -------
        instance of itself
            For integer values, or instances of itself.
        :class:`EnumView` or its subclass
            For value-castables, as defined by the ``view_class`` keyword argument.
        :class:`Value`
            For value-castables, when a view class is not specified for this enum.
        
amaranth/lib/enum.py