def _unify(shapes):
        """Returns the minimal shape that contains all shapes from the list.

        If no shapes passed in, returns unsigned(0).
        """
        unsigned_width = signed_width = 0
        has_signed = False
        for shape in shapes:
            assert isinstance(shape, Shape)
            if shape.signed:
                has_signed = True
                signed_width = max(signed_width, shape.width)
            else:
                unsigned_width = max(unsigned_width, shape.width)
        # If all shapes unsigned, simply take max.
        if not has_signed:
            return unsigned(unsigned_width)
        # Otherwise, result is signed. All unsigned inputs, if any,
        # need to be converted to signed by adding a zero bit.
        return signed(max(signed_width, unsigned_width + 1))
Returns the minimal shape that contains all shapes from the list.

        If no shapes passed in, returns unsigned(0).
        
amaranth/hdl/_ast.py