def METHOD_NAME(self, *, base, target, annotation_type, data):
    """
    Stores a diff annotation to the repo's sqlite database,
    and returns the annotation itself.
    base: base Tree or Commit object for this diff (revA in a 'revA...revB' diff)
    target: target Tree or Commit object for this diff (revB in a 'revA...revB' diff)
    """
    assert isinstance(data, dict)
    object_id = self._object_id(base, target)
    data = json.dumps(data)
    with annotations_session(self.repo) as session:
        if session.is_readonly:
            L.info("Can't store annotation; annotations.db is read-only")
        else:
            L.debug(
                "storing: %s for %s: %s",
                annotation_type,
                object_id,
                data,
            )
            try:
                session.add(
                    KartAnnotation(
                        object_id=object_id,
                        annotation_type=annotation_type,
                        data=data,
                    )
                )
            except OperationalError as e:
                # ignore errors from readonly databases.
                # this can happen if the db already existed, with tables already created,
                # since annotations_session() wouldn't have run any CREATE commands in that
                # case (and hence we don't yet know if the session is readonly)
                if "readonly database" in str(e):
                    L.info("Can't store annotation; annotations.db is read-only")
                else:
                    raise
    return data