def __invert__(self):
        """Inverts all flags in this value and returns another :class:`FlagView`.

        Note that this is not equivalent to applying bitwise negation to the underlying value:
        just like the Python :class:`enum.Flag` class, only bits corresponding to flags actually
        defined in the enumeration are included in the result.

        Returns
        -------
        :class:`FlagView`
        """
        enum_cls = self.shape()
        if hasattr(enum_cls, "_boundary_") and enum_cls._boundary_ in (EJECT, KEEP):
            return enum_cls._amaranth_view_class_(enum_cls, ~self.as_value())
        else:
            singles_mask = 0
            for flag in enum_cls:
                if (flag.value & (flag.value - 1)) == 0:
                    singles_mask |= flag.value
            return enum_cls._amaranth_view_class_(enum_cls, ~self.as_value() & singles_mask)
Inverts all flags in this value and returns another :class:`FlagView`.

        Note that this is not equivalent to applying bitwise negation to the underlying value:
        just like the Python :class:`enum.Flag` class, only bits corresponding to flags actually
        defined in the enumeration are included in the result.

        Returns
        -------
        :class:`FlagView`
        
amaranth/lib/enum.py