Skip to content

Commit 78d6bbf

Browse files
vintaclaude
andcommitted
fix: match audit_priority entries by name or URL across revisions
Entries were matched across revisions by normalized name only, so a rename (dateutil to python-dateutil, mock to unittest.mock) showed as one removal plus one addition and flagged the section as changed since its audit. Co-Authored-By: Claude <noreply@anthropic.com>
1 parent c3a4b18 commit 78d6bbf

1 file changed

Lines changed: 15 additions & 7 deletions

File tree

‎.claude/skills/audit-the-list/scripts/audit_priority.py‎

Lines changed: 15 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -30,17 +30,25 @@ def git(*args: str) -> str:
3030

3131

3232
@cache
33-
def entries_at(rev: str) -> dict[str, dict[str, str]]:
34-
"""Section -> {normalized entry name: display name}, so a recased or re-punctuated name is no change."""
33+
def entries_at(rev: str) -> dict[str, dict[str, set[str]]]:
34+
"""Section -> {display name: {normalized name, normalized URL}}.
35+
36+
An entry matches across revisions on either key, so a rename that keeps its link, or a link fix that keeps its name, is no change.
37+
"""
3538
sections = {}
3639
for group in parse_readme(git("show", f"{rev}:README.md")):
3740
for category in group["categories"]:
38-
names = [entry["name"] for entry in category["entries"]]
39-
names += [sub["name"] for entry in category["entries"] for sub in entry["also_see"]]
40-
sections[category["name"]] = {re.sub(r"[-_.]+", "-", name).lower(): name for name in names}
41+
links = [*category["entries"], *(sub for entry in category["entries"] for sub in entry["also_see"])]
42+
sections[category["name"]] = {link["name"]: {re.sub(r"[-_.]+", "-", link["name"]).lower(), link["url"].rstrip("/").lower()} for link in links}
4143
return sections
4244

4345

46+
def missing(entries: dict[str, set[str]], other: dict[str, set[str]]) -> list[str]:
47+
"""Display names in entries that match no entry in other."""
48+
keys = set().union(*other.values())
49+
return [name for name, own in entries.items() if not own & keys]
50+
51+
4452
def resolve(text: str, groups: dict[str, list[str]]) -> list[str]:
4553
"""Sections named in text, longest name first so "Database Drivers" never counts as "Database"."""
4654
found = []
@@ -94,8 +102,8 @@ def stamp(section: str, timestamp: int, date: str, rev: str) -> None:
94102
for section in group_of:
95103
_, date, rev = last.get(section, (0, "never", REFORM))
96104
before = entries_at(rev).get(section, {})
97-
added = [head[section][n] for n in head[section].keys() - before.keys()]
98-
removed = [before[n] for n in before.keys() - head[section].keys()]
105+
added = missing(head[section], before)
106+
removed = missing(before, head[section])
99107
row = (section, date, rev[:7] if section in last else "", added, removed)
100108
(changed if added or removed else unchanged).append(row)
101109

0 commit comments

Comments
 (0)