Skip to content

Commit 15ec5a9

Browse files
committed
Fix mypy attr-defined in ApplyAnalysisReuseTests
The new test typed the captured-analyses list as list[object], so mypy rejected the .id access in the reuse assertion ([attr-defined]). Type it list[Analysis | None] and narrow the reused element with an assert before reading .id.
1 parent e232766 commit 15ec5a9

1 file changed

Lines changed: 4 additions & 3 deletions

File tree

opencontractserver/tests/test_crawl_authorities.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -306,7 +306,7 @@ def _ingest_same_corpus(
306306
"canonical_key": frontier_row.canonical_key,
307307
}
308308

309-
seen_analyses: list[object] = []
309+
seen_analyses: list[Analysis | None] = []
310310

311311
def _mock_apply(
312312
*, corpus_id, creator_id, types=None, analysis=None, extra_tiers=None
@@ -352,8 +352,9 @@ def _mock_apply(
352352
# First section lets apply mint the provenance Analysis (None passed in);
353353
# the second section REUSES it rather than minting a second row.
354354
self.assertIsNone(seen_analyses[0])
355-
self.assertIsNotNone(seen_analyses[1])
356-
self.assertEqual(seen_analyses[1].id, provenance.id)
355+
reused = seen_analyses[1]
356+
assert reused is not None # narrows Analysis | None -> Analysis for mypy
357+
self.assertEqual(reused.id, provenance.id)
357358
# No second enrichment Analysis was created for the corpus.
358359
self.assertEqual(
359360
Analysis.objects.filter(analyzed_corpus=corpus).count(),

0 commit comments

Comments
 (0)