|
11 | 11 |
|
12 | 12 | import functools |
13 | 13 | import os |
14 | | -from dataclasses import dataclass |
15 | 14 | from pathlib import Path |
16 | 15 | from typing import TYPE_CHECKING, Annotated, cast |
17 | 16 |
|
@@ -308,14 +307,14 @@ async def _run_ingest( # noqa: PLR0913, PLR0912, PLR0915, C901 - the ingest CLI |
308 | 307 | valid = ", ".join(sorted(_SOURCE_REGISTRY)) |
309 | 308 | msg = f"--only-source: unknown source {only_source!r}. Valid: {valid}." |
310 | 309 | raise typer.BadParameter(msg) |
311 | | - spec = _SOURCE_REGISTRY[only_source] |
| 310 | + source_class = _SOURCE_REGISTRY[only_source] |
312 | 311 | # Each opt-in source's --enable-* flag needs an explicit branch here — |
313 | 312 | # Python's keyword-only parameter binding can't be table-driven without |
314 | 313 | # ``locals()`` tricks. Add one when introducing a new opt-in source. |
315 | | - if spec.source_class is TavilyNewsSource: |
| 314 | + if source_class is TavilyNewsSource: |
316 | 315 | enable_tavily_news = True |
317 | 316 | # crunchbase_csv is gated by a path argument, not a boolean — require it explicitly. |
318 | | - if spec.source_class is CrunchbaseCsvSource and crunchbase_csv is None: |
| 317 | + if source_class is CrunchbaseCsvSource and crunchbase_csv is None: |
319 | 318 | msg = "--only-source crunchbase_csv requires --crunchbase-csv PATH." |
320 | 319 | raise typer.BadParameter(msg) |
321 | 320 |
|
@@ -351,7 +350,7 @@ async def _run_ingest( # noqa: PLR0913, PLR0912, PLR0915, C901 - the ingest CLI |
351 | 350 | ) |
352 | 351 |
|
353 | 352 | if only_source is not None: |
354 | | - wanted_class = _SOURCE_REGISTRY[only_source].source_class |
| 353 | + wanted_class = _SOURCE_REGISTRY[only_source] |
355 | 354 | sources = [s for s in sources if isinstance(s, wanted_class)] |
356 | 355 | if not sources: |
357 | 356 | msg = ( |
@@ -452,16 +451,11 @@ async def _run_ingest( # noqa: PLR0913, PLR0912, PLR0915, C901 - the ingest CLI |
452 | 451 | typer.echo(f"slopmortem ingest result: {result} cost=${budget.spent_usd:.4f}") |
453 | 452 |
|
454 | 453 |
|
455 | | -@dataclass(frozen=True) |
456 | | -class _SourceSpec: |
457 | | - source_class: type[Source] |
458 | | - |
459 | | - |
460 | | -_SOURCE_REGISTRY: dict[str, _SourceSpec] = { |
461 | | - "curated": _SourceSpec(source_class=CuratedSource), |
462 | | - "hn_algolia": _SourceSpec(source_class=HNAlgoliaSource), |
463 | | - "crunchbase_csv": _SourceSpec(source_class=CrunchbaseCsvSource), |
464 | | - "tavily_news": _SourceSpec(source_class=TavilyNewsSource), |
| 454 | +_SOURCE_REGISTRY: dict[str, type[Source]] = { |
| 455 | + "curated": CuratedSource, |
| 456 | + "hn_algolia": HNAlgoliaSource, |
| 457 | + "crunchbase_csv": CrunchbaseCsvSource, |
| 458 | + "tavily_news": TavilyNewsSource, |
465 | 459 | } |
466 | 460 |
|
467 | 461 |
|
|
0 commit comments