INNER CODE UNIT · Python
include_newly_trailing_whitespace
uber/NullAway · scripts/nullaway-suppression-remover/src/suppression_remover/core.py:221
def include_newly_trailing_whitespace(data: bytes, start: int, end: int) -> int:
"""Expand an edit to remove whitespace it would newly leave at line end."""
if re.match(rb"[ \t]*(?:\r?\n|$)", data[end:]):
return len(data[:start].rstrip(b" \t"))
return start
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