INNER CODE UNIT · Python
target_annotation
uber/NullAway · scripts/nullaway-suppression-remover/src/suppression_remover/core.py:227
def target_annotation(data: bytes) -> Optional[ts.Node]:
"""Find the suppression annotation in *data* that still has a target value."""
tree = _get_parser().parse(data)
for node in find_suppress_warnings_nodes(tree.root_node):
if any(
literal.text
and literal.text.decode()[1:-1] in suppression_names
for literal in _string_literal_nodes(node)
):
return node
return None
# First remove values that occupy a line by themselves. This produces the natural
# formatting for the common one-value-per-line style.
annotation = target_annotation(source)
if annotation is None:
raise ValueError("Could not reparse @SuppressWarnings annotation")
literals = _string_literal_nodes(annotation)