def __instancecheck__(cls, instance):
        """
        Override of :py:`isinstance(obj, Signature)`.

        In addition to the standard behavior of :func:`isinstance`, this override makes
        :py:`isinstance(obj, cls)` act as :py:`isinstance(obj.flip(), cls)` where
        :py:`obj` is an instance of :class:`FlippedSignature`.
        """

        # `FlippedSignature` is an instance of a `Signature` or its subclass if the unflipped
        # object is.
        if type(instance) is FlippedSignature:
            return super().__instancecheck__(instance.flip())
        return super().__instancecheck__(instance)

        Override of :py:`isinstance(obj, Signature)`.

        In addition to the standard behavior of :func:`isinstance`, this override makes
        :py:`isinstance(obj, cls)` act as :py:`isinstance(obj.flip(), cls)` where
        :py:`obj` is an instance of :class:`FlippedSignature`.
        
amaranth/lib/wiring.py