Skip to content

Commit 1b4b6f3

Browse files
authored
fix: parse daily scraper CLI through CliApp (#1498)
daily-scraper keeps output_dir required because the systemd service passes --output-dir explicitly. Calling CliArgs() made zuban treat output_dir as a missing constructor argument during image builds, even though pydantic-settings would populate it from the CLI at runtime. Use CliApp.run(CliArgs) behind parse_args() so pydantic-settings owns argv parsing and returns a typed CliArgs instance. The existing settings_customise_sources hook still drops env, dotenv, and secrets sources, so the CLI contract remains explicit and the strict build check no longer sees a missing required constructor argument. <!-- Macroscope's pull request summary starts here --> <!-- Macroscope will only edit the content between these invisible markers, and the markers themselves will not be visible in the GitHub rendered markdown. --> <!-- If you delete either of the start / end markers from your PR's description, Macroscope will append its summary at the bottom of the description. --> > [!NOTE] > ### Parse daily scraper CLI arguments through `CliApp` instead of direct instantiation > Adds a `parse_args()` function in [`__init__.py`](https://github.com/indexable-inc/index/pull/1498/files#diff-3d7ecea4ccb31f30c8f5a7e0338a71c43ed77aa239d4ed3c988d8ce9ec924b9c) that delegates argument parsing to `CliApp.run(CliArgs)` from `pydantic_settings`. The `main` entrypoint now calls `parse_args()` instead of constructing `CliArgs()` directly, so CLI-provided argument values are respected at runtime. > > <!-- Macroscope's review summary starts here --> > > <sup><a href="https://app.macroscope.com">Macroscope</a> summarized 8666740.</sup> > <!-- Macroscope's review summary ends here --> > <!-- macroscope-ui-refresh --> <!-- Macroscope's pull request summary ends here -->
1 parent 5f187c5 commit 1b4b6f3

1 file changed

Lines changed: 12 additions & 2 deletions

File tree

  • examples/python-daily-scraper/src/daily_scraper

examples/python-daily-scraper/src/daily_scraper/__init__.py

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,13 @@
77
import duckdb
88
import httpx
99
from pydantic import BaseModel
10-
from pydantic_settings import BaseSettings, CliSettingsSource, PydanticBaseSettingsSource, SettingsConfigDict
10+
from pydantic_settings import (
11+
BaseSettings,
12+
CliApp,
13+
CliSettingsSource,
14+
PydanticBaseSettingsSource,
15+
SettingsConfigDict,
16+
)
1117

1218

1319
LOGGER = logging.getLogger("daily_scraper")
@@ -136,9 +142,13 @@ def write_parquet(metric: RepoMetric, output_dir: Path) -> Path:
136142
return output_path
137143

138144

145+
def parse_args() -> CliArgs:
146+
return CliApp.run(CliArgs)
147+
148+
139149
def main() -> None:
140150
logging.basicConfig(level=logging.INFO, format="%(levelname)s %(message)s")
141-
args = CliArgs()
151+
args = parse_args()
142152

143153
metric = fetch_repo_metric(
144154
repo=args.repo,

0 commit comments

Comments
 (0)