def get_annotation_type(leaf: Leaf) -> Literal["return", "param", None]:
    """Returns the type of annotation this leaf is part of, if any."""
    ancestor = leaf.parent
    while ancestor is not None:
        if ancestor.prev_sibling and ancestor.prev_sibling.type == token.RARROW:
            return "return"
        if ancestor.parent and ancestor.parent.type == syms.tname:
            return "param"
        ancestor = ancestor.parent
    return None
Returns the type of annotation this leaf is part of, if any.
src/black/nodes.py