Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 15 additions & 5 deletions scripts/pr_review.py
Original file line number Diff line number Diff line change
Expand Up @@ -2582,13 +2582,23 @@ def total_section_entries(pr: dict) -> int:
return sum(linked for role, _, _, linked in sections if role == TOTAL)


def open_entry_ids(pr: dict) -> set[str]:
"""The distinct title anchors the head round's open entries link, resolved sections left out."""
def open_entry_links(pr: dict) -> list[list[str]]:
"""The thread ids each of the head round's open entries links, resolved sections left out."""
newest = second_format_head(pr)
if newest is None:
return set()
return []
sections = read_overview(newest.get("body") or "")[2]
return {entry[0] for role, _, ids, _ in sections if role != RESOLVED for entry in ids}
return [entry for role, _, ids, _ in sections if role != RESOLVED for entry in ids]


def open_entry_ids(pr: dict) -> set[str]:
"""The distinct title anchors the head round's open entries link."""
return {entry[0] for entry in open_entry_links(pr)}


def open_linked_ids(pr: dict) -> set[str]:
"""Every thread id the head round's open entries link, back-references included."""
return {found for entry in open_entry_links(pr) for found in entry}


TABLE_VOTES = re.compile(r"\(\d+ votes?\b[^()]*\)")
Expand Down Expand Up @@ -2755,7 +2765,7 @@ def headline_shortfall(pr: dict) -> tuple[int, int]:
)
withheld = suppressed_blocks(body) + previously_missed_blocks(body)
accounted = max(listed, stated_total(body) or 0) + sum(map(finding_count, withheld))
return stated, accounted + len(earlier_round_threads(pr, newest) - open_entry_ids(pr))
return stated, accounted + len(earlier_round_threads(pr, newest) - open_linked_ids(pr))


PROSE_FINDINGS = re.compile(
Expand Down
12 changes: 12 additions & 0 deletions tests/test_pr_review.py
Original file line number Diff line number Diff line change
Expand Up @@ -5240,6 +5240,18 @@ def test_an_earlier_thread_an_open_entry_links_is_counted_once(self) -> None:
out = pr_review.digest("o", "r", 7)[0]
self.assertIn("account for 2", out)

def test_a_back_reference_an_open_entry_links_is_not_counted_again(self) -> None:
"""An earlier thread linked beside an entry's own is already in the listed entries."""
body = with_table_findings(TABLE_LISTED, "Three unresolved findings remain.")
own = "(#discussion_r4000000002) New"
self.assertIn(own, body)
body = body.replace(own, f"{own}, same cause as [earlier](#discussion_r4000000009)")
old, threads = earlier_round("4000000009", resolved=False)
out = self.digest(body, [old], threads)
self.assertIn("FINDINGS WITH NO THREAD (1)", out)
self.assertIn("its headline states 3 findings where", out)
self.assertIn("account for 2", out)

def test_a_clean_round_summing_up_its_resolved_findings_reports_nothing(self) -> None:
body = overview_v2_revised().replace(
"One reader still needs a look.", "All three earlier findings are resolved."
Expand Down
Loading