diff --git a/scripts/language_stats.py b/scripts/language_stats.py index 6588ff2..690c0c7 100644 --- a/scripts/language_stats.py +++ b/scripts/language_stats.py @@ -19,6 +19,7 @@ Optional environment variables -------------------------------- STATE_FILE path to store last-run state (default: ~/.local/state/language_stats.json) """ + import argparse import base64 import json @@ -137,7 +138,9 @@ def has_new_commits(current_timestamps: dict[str, str], saved_state: dict) -> bo return False -def aggregate_language_bytes(session: requests.Session, repos: list[dict]) -> dict[str, int]: +def aggregate_language_bytes( + session: requests.Session, repos: list[dict] +) -> dict[str, int]: """Aggregate language byte counts across all repositories.""" totals: dict[str, int] = defaultdict(int) @@ -148,12 +151,18 @@ def aggregate_language_bytes(session: requests.Session, repos: list[dict]) -> di ) if not resp.ok: # Skip repos we can't access (e.g., token scope limitations) - print(f"Warning: Could not fetch languages for {repo['name']}: {resp.status_code}", file=sys.stderr) + print( + f"Warning: Could not fetch languages for {repo['name']}: {resp.status_code}", + file=sys.stderr, + ) continue langs = resp.json() # Skip error responses (e.g., {"message": "..."}) if not isinstance(langs, dict) or "message" in langs: - print(f"Warning: Unexpected response for {repo['name']}: {langs}", file=sys.stderr) + print( + f"Warning: Unexpected response for {repo['name']}: {langs}", + file=sys.stderr, + ) continue for lang, bytes_ in langs.items(): # Handle bytes as either int or string @@ -166,7 +175,9 @@ def aggregate_language_bytes(session: requests.Session, repos: list[dict]) -> di return dict(totals) -def subtract_excluded_files(session: requests.Session, totals: dict[str, int]) -> dict[str, int]: +def subtract_excluded_files( + session: requests.Session, totals: dict[str, int] +) -> dict[str, int]: """Subtract byte counts for explicitly excluded files.""" for repo_name, file_path, language in EXCLUDE_FILES: try: