From 941f1c6e07fe954954c52ce2172fef03502dc838 Mon Sep 17 00:00:00 2001 From: Bryan Van Deusen Date: Thu, 24 Sep 2026 08:20:12 -0400 Subject: [PATCH] =?UTF-8?q?fix:=20run=207464's=20two=20failures=20?= =?UTF-8?q?=E2=80=94=20an=20unused=20loop=20target=20and=20a=20missed=20ca?= =?UTF-8?q?ll=20site=20(4392)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Both mine, both from the same change. `identity` is unpacked in the write loop and never read there — the decision it feeds happens above it, when `conclusive` is built. flake8-bugbear is on repo-wide and B007 is exactly this. Renamed `_identity`, and `linked += status == "linked"` spelled out as the `if` it actually is. The second is worse, because it was a real assertion silently pointed at the wrong shape. `match_post` now returns `(proposed, linked)`, and when I rewrote the call sites I matched on `) == 0` — so the one comparison in the file that reads `) == 1` kept comparing a tuple to an integer. Found by walking the module's AST for every comparison against `match_post` and every use of a name assigned from it, rather than grepping again with the pattern that had already missed it once. Co-Authored-By: Claude Opus 5 Claude-Session: https://claude.ai/code/session_01LVjrnpQjRgHdvq95rASoiR --- backend/app/services/post_association_service.py | 5 +++-- tests/test_post_association.py | 2 +- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/backend/app/services/post_association_service.py b/backend/app/services/post_association_service.py index 399713c..ddab64f 100644 --- a/backend/app/services/post_association_service.py +++ b/backend/app/services/post_association_service.py @@ -391,9 +391,10 @@ class PostAssociationService: auto_id = conclusive[0][0].id linked = 0 - for group, score, signals, identity in scored: + for group, score, signals, _identity in scored: status = "linked" if group.id == auto_id else "pending" - linked += status == "linked" + if status == "linked": + linked += 1 self.session.add(PostAssociation( announcement_post_id=announcement.id, payload_post_id=group.id, diff --git a/tests/test_post_association.py b/tests/test_post_association.py index 2535451..c7c6bed 100644 --- a/tests/test_post_association.py +++ b/tests/test_post_association.py @@ -306,7 +306,7 @@ async def test_a_dismissed_pair_is_never_proposed_again(db): svc = PostAssociationService(db) assert await svc.match_post( teaser.id, threshold=DEFAULT_THRESHOLD, window_hours=WINDOW, - ) == 1 + ) == (1, 0) await db.commit() assoc = (await db.execute(select(PostAssociation))).scalar_one()