def __eq__(self, other):
        """Compares the underlying value for equality.

        The other operand has to be either another :class:`EnumView` with the same enum type, or
        a plain value of the underlying enum.

        Returns
        -------
        :class:`Value`
            The result of the equality comparison, as a single-bit value.
        """
        enum_cls = self.shape()
        if isinstance(other, enum_cls):
            other = enum_cls(Value.cast(other))
        if not isinstance(other, EnumView) or other.shape() is not enum_cls:
            raise TypeError("an EnumView can only be compared to value or other EnumView of "
                            "the same enum type")
        return self.as_value() == other.as_value()
Compares the underlying value for equality.

        The other operand has to be either another :class:`EnumView` with the same enum type, or
        a plain value of the underlying enum.

        Returns
        -------
        :class:`Value`
            The result of the equality comparison, as a single-bit value.
        
amaranth/lib/enum.py