def _make_singlar_property(attribute, attribute_singular):
    """Make a property which forwards gets/sets to attribute, assuming it is a
    list with a single entry.
    """

    def getter(self):
        items = getattr(self, attribute)
        assert len(items) == 1, f"expected 1 {attribute_singular}, got {len(items)}"
        return items[0]

    def setter(self, new_val):
        return setattr(self, attribute, [new_val])

    return property(getter, setter, doc=f"singular accessor for {attribute}")