INNER CODE UNIT · Python

_rewrite_multiline_annotation

uber/NullAway · scripts/nullaway-suppression-remover/src/suppression_remover/core.py:208

def _rewrite_multiline_annotation(
    annotation_text: str, suppression_names: set[str]
) -> tuple[str, set[int]]:
    """Remove selected suppression strings without flattening a multiline annotation.

    A suppression occupying its own line is removed together with that line. For a
    suppression sharing a line with another value, the smallest adjacent comma-delimited
    region is removed. All other annotation text, including braces and indentation, is
    retained.
    """
    source = annotation_text.encode("utf-8")
    deleted_lines: set[int] = set()

    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

View source record →

📰 Research Paper
Loading…
⏳ Fetching content…