style: apply ruff format and fix lint issues in playoff modules
CI / Lint (push) Successful in 8s
CI / Test (push) Successful in 10s
CI / Build & Push (push) Successful in 22s

- Rename single-letter `l` loop variables in bracket_view to satisfy E741
- Drop unused `json` import from test_playoff_cache (F401/F811)

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
This commit is contained in:
2026-04-19 12:48:42 -04:00
parent ebe770fecd
commit 930247b32f
8 changed files with 65 additions and 32 deletions
+7 -7
View File
@@ -34,13 +34,13 @@ def build_bracket_view(year, bracket_payload, fetched_at=None):
def slot(letter):
return _matchup(year, letter, series_by_letter.get(letter))
east_r1 = [slot(l) for l in EAST_R1]
west_r1 = [slot(l) for l in WEST_R1]
east_r2 = [slot(l) for l in EAST_R2]
west_r2 = [slot(l) for l in WEST_R2]
east_cf = [slot(l) for l in EAST_CF]
west_cf = [slot(l) for l in WEST_CF]
cup = [slot(l) for l in CUP_FINAL]
east_r1 = [slot(ltr) for ltr in EAST_R1]
west_r1 = [slot(ltr) for ltr in WEST_R1]
east_r2 = [slot(ltr) for ltr in EAST_R2]
west_r2 = [slot(ltr) for ltr in WEST_R2]
east_cf = [slot(ltr) for ltr in EAST_CF]
west_cf = [slot(ltr) for ltr in WEST_CF]
cup = [slot(ltr) for ltr in CUP_FINAL]
return {
"year": year,
+5 -3
View File
@@ -30,9 +30,11 @@ def series_id(game):
return None
start = game.get("startTimeUTC") or ""
try:
year = datetime.fromisoformat(start.replace("Z", "+00:00")).astimezone(
EASTERN
).year
year = (
datetime.fromisoformat(start.replace("Z", "+00:00"))
.astimezone(EASTERN)
.year
)
except (ValueError, AttributeError):
year = datetime.now(EASTERN).year
return f"{year}-{letter.upper()}"
+10 -4
View File
@@ -21,8 +21,8 @@ logger = logging.getLogger(__name__)
EASTERN = ZoneInfo("America/New_York")
BRACKET_TTL = 3600 # refresh at this cadence via scheduler
SERIES_TTL = 300 # lazy cache for per-series schedule fetches
BRACKET_TTL = 3600 # refresh at this cadence via scheduler
SERIES_TTL = 300 # lazy cache for per-series schedule fetches
MAX_STALE_SECONDS = 86400 # 24h
SERIES_ID_RE = re.compile(r"^(20\d{2})-([A-P])$")
@@ -78,6 +78,7 @@ def _get(cache_key):
# ── Bracket ────────────────────────────────────────────────────────
def bracket_key(year):
return f"bracket:{year}"
@@ -109,6 +110,7 @@ def get_bracket(year=None):
# ── Per-series schedule ────────────────────────────────────────────
def series_key(season, letter):
return f"series:{season}:{letter.upper()}"
@@ -140,7 +142,9 @@ def fetch_series(series_id):
if time.time() - fetched < SERIES_TTL:
return payload
url = f"https://api-web.nhle.com/v1/schedule/playoff-series/{season}/{letter.lower()}"
url = (
f"https://api-web.nhle.com/v1/schedule/playoff-series/{season}/{letter.lower()}"
)
try:
resp = requests.get(url, timeout=10)
resp.raise_for_status()
@@ -189,7 +193,9 @@ def record_start_date_if_missing(scoreboard_games, now=None):
now = now or datetime.now(EASTERN)
today = now.date().isoformat()
_put(META_KEY, {"first_date": today, "recorded_at_utc": now.astimezone().isoformat()})
_put(
META_KEY, {"first_date": today, "recorded_at_utc": now.astimezone().isoformat()}
)
return today