INNER CODE UNIT · Python
find_annotations
uber/NullAway · scripts/nullaway-suppression-remover/src/suppression_remover/core.py:320
def find_annotations(
file_path: Path, checker: str, alt_suppressions: list[str] | None = None
) -> list[Annotation]:
"""Return all Annotation objects in *file_path* containing *checker* or any alt."""
all_suppressions = set([checker] + (alt_suppressions or []))
source = file_path.read_bytes()
lines = source.decode("utf-8").splitlines(keepends=True)
annotations: list[Annotation] = []
tree = _get_parser().parse(source)
for node in find_suppress_warnings_nodes(tree.root_node):
checkers = annotation_checkers(node)
if any(c in all_suppressions for c in checkers):
start_line = node.start_point[0] + 1
end_line = node.end_point[0] + 1
annotations.append(
Annotation(
start_line=start_line,