Format language_stats.py with black

This commit is contained in:
Mark Eaton committed 2026-11-11 19:52:08 -05:00
1 parent 1188b72263
commit 73d2a83250
1 file changed
+15 -4
+15 -4
View File
@@ -19,6 +19,7 @@ Optional environment variables
-------------------------------- --------------------------------
STATE_FILE path to store last-run state (default: ~/.local/state/language_stats.json) STATE_FILE path to store last-run state (default: ~/.local/state/language_stats.json)
""" """
import argparse import argparse
import base64 import base64
import json import json
@@ -137,7 +138,9 @@ def has_new_commits(current_timestamps: dict[str, str], saved_state: dict) -> bo
return False 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.""" """Aggregate language byte counts across all repositories."""
totals: dict[str, int] = defaultdict(int) 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: if not resp.ok:
# Skip repos we can't access (e.g., token scope limitations) # 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 continue
langs = resp.json() langs = resp.json()
# Skip error responses (e.g., {"message": "..."}) # Skip error responses (e.g., {"message": "..."})
if not isinstance(langs, dict) or "message" in langs: 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 continue
for lang, bytes_ in langs.items(): for lang, bytes_ in langs.items():
# Handle bytes as either int or string # 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) 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.""" """Subtract byte counts for explicitly excluded files."""
for repo_name, file_path, language in EXCLUDE_FILES: for repo_name, file_path, language in EXCLUDE_FILES:
try: try: