Skip to content

migrate_remove_annotation

Source code in src/library_analyzer/processing/migration/annotations/_migrate_remove_annotation.py
def migrate_remove_annotation(origin_annotation: RemoveAnnotation, mapping: Mapping) -> list[AbstractAnnotation]:
    annotated_apiv1_element = get_annotated_api_element(origin_annotation, mapping.get_apiv1_elements())
    if annotated_apiv1_element is None:
        return []

    remove_annotations: list[AbstractAnnotation] = []
    for element in mapping.get_apiv2_elements():
        remove_annotation = deepcopy(origin_annotation)
        authors = remove_annotation.authors
        authors.append(migration_author)
        remove_annotation.authors = authors
        if (
            isinstance(element, type(annotated_apiv1_element))
            and is_removeable(element)
            and not isinstance(element, Attribute | Result)
        ):
            remove_annotations.append(
                RemoveAnnotation(
                    element.id,
                    authors,
                    remove_annotation.reviewers,
                    remove_annotation.comment,
                    EnumReviewResult.NONE,
                ),
            )
        elif not isinstance(element, Attribute | Result):
            remove_annotations.append(
                TodoAnnotation(
                    element.id,
                    authors,
                    remove_annotation.reviewers,
                    remove_annotation.comment,
                    EnumReviewResult.NONE,
                    get_migration_text(remove_annotation, mapping, for_todo_annotation=True),
                ),
            )
    return remove_annotations