def __and__(self, other):
        """Narrow the set of possible directions.

        * :py:`self & self` returns :py:`self`.
        * :py:`Bidir & other` returns :py:`other`.
        * :py:`Input & Output` raises :exc:`ValueError`.
        """
        if not isinstance(other, Direction):
            return NotImplemented
        if self == other:
            return self
        elif self is Direction.Bidir:
            return other
        elif other is Direction.Bidir:
            return self
        else:
            raise ValueError("Cannot combine input port with output port")
Narrow the set of possible directions.

        * :py:`self & self` returns :py:`self`.
        * :py:`Bidir & other` returns :py:`other`.
        * :py:`Input & Output` raises :exc:`ValueError`.
        
amaranth/lib/io.py