mirror of
https://github.com/vinta/awesome-python.git
synced 2026-05-06 14:17:15 -04:00
refactor(build): remove StarData TypedDict, loosen load_stars return to dict[str, dict]
Cache-write shape mismatches the TypedDict and callers mix .get() and direct access, so the stricter type was providing false safety. Using dict[str, dict] accurately reflects the actual runtime contract. Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
+1
-10
@@ -6,19 +6,10 @@ import re
|
||||
import shutil
|
||||
from datetime import UTC, datetime
|
||||
from pathlib import Path
|
||||
from typing import TypedDict
|
||||
|
||||
from jinja2 import Environment, FileSystemLoader
|
||||
from readme_parser import ParsedGroup, ParsedSection, parse_readme, parse_sponsors
|
||||
|
||||
|
||||
class StarData(TypedDict):
|
||||
stars: int
|
||||
owner: str
|
||||
last_commit_at: str
|
||||
fetched_at: str
|
||||
|
||||
|
||||
GITHUB_REPO_URL_RE = re.compile(r"^https?://github\.com/([^/]+/[^/]+?)(?:\.git)?/?$")
|
||||
|
||||
SOURCE_TYPE_DOMAINS = {
|
||||
@@ -46,7 +37,7 @@ def extract_github_repo(url: str) -> str | None:
|
||||
return m.group(1) if m else None
|
||||
|
||||
|
||||
def load_stars(path: Path) -> dict[str, StarData]:
|
||||
def load_stars(path: Path) -> dict[str, dict]:
|
||||
"""Load star data from JSON. Returns empty dict if file doesn't exist or is corrupt."""
|
||||
if path.exists():
|
||||
try:
|
||||
|
||||
Reference in New Issue
Block a user