Skip to content

Commit c880113

Browse files
fix: resolve mypy type errors in insights router
- Remove type: ignore on dict.fromkeys (use untyped form) - Fix POTD candidate tuple types (str, not str | None) - Use Spec type instead of object in _collect_impl_tags and scored list - Import Spec from core.database Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
1 parent 722fa81 commit c880113

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

api/routers/insights.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
from api.cache import cache_key, get_or_set_cache
2121
from api.dependencies import require_db
2222
from core.constants import SUPPORTED_LIBRARIES
23-
from core.database import ImplRepository, SpecRepository
23+
from core.database import ImplRepository, Spec, SpecRepository
2424
from core.database.connection import get_db_context
2525
from core.utils import strip_noqa_comments
2626

@@ -219,7 +219,7 @@ async def _build_dashboard(repo: SpecRepository, impl_repo: ImplRepository) -> D
219219
all_scores: list[float] = []
220220

221221
library_scores: dict[str, list[float]] = {lib: [] for lib in SUPPORTED_LIBRARIES}
222-
library_counts: dict[str, int] = dict.fromkeys(SUPPORTED_LIBRARIES, 0) # type: ignore[arg-type]
222+
library_counts = dict.fromkeys(SUPPORTED_LIBRARIES, 0)
223223

224224
tag_counter: dict[str, Counter[str]] = defaultdict(Counter)
225225
monthly_counts: Counter[str] = Counter()
@@ -368,7 +368,7 @@ async def _build_potd(spec_repo: SpecRepository, impl_repo: ImplRepository) -> P
368368
today = date.today().isoformat()
369369

370370
# Collect candidates: implementations with quality_score >= 90 (lightweight, no code loaded)
371-
candidates: list[tuple[str, str, str, str | None, float, str | None]] = []
371+
candidates: list[tuple[str, str, str, str, float, str]] = []
372372
for spec in all_specs:
373373
for impl in spec.impls:
374374
if impl.quality_score is not None and impl.quality_score >= 90 and impl.preview_url:
@@ -428,7 +428,7 @@ async def _fetch() -> PlotOfTheDayResponse | None:
428428
# =============================================================================
429429

430430

431-
def _collect_impl_tags(spec: object, library: str | None = None) -> set[str]:
431+
def _collect_impl_tags(spec: Spec, library: str | None = None) -> set[str]:
432432
"""Collect spec-level tags + impl-level tags for a spec.
433433
434434
If library is specified, only include that library's impl_tags.
@@ -471,7 +471,7 @@ async def _build_related(
471471
return RelatedSpecsResponse(related=[])
472472

473473
# Compute similarity for all other specs
474-
scored: list[tuple[float, list[str], object]] = []
474+
scored: list[tuple[float, list[str], Spec]] = []
475475
for spec in all_specs:
476476
if spec.id == spec_id:
477477
continue

0 commit comments

Comments
 (0)