def is_part_of_annotation(leaf: Leaf) -> bool:
    """Returns whether this leaf is part of a type annotation."""
    assert leaf.parent is not None
    return get_annotation_type(leaf) is not None
Returns whether this leaf is part of a type annotation.
src/black/nodes.py