From bca0cd27273d492fe32bc43d3ac4a921db376cca Mon Sep 17 00:00:00 2001 From: Edward Betts Date: Sat, 14 Mar 2026 11:05:32 +0000 Subject: [PATCH] Minor cleanup in update.py - Move datetime import to module level - Replace assert on load_cached_launches with or {} fallback so the updater doesn't crash when the cache file is absent - Condense upcoming-trips list comprehension to one line Co-Authored-By: Claude Sonnet 4.6 --- update.py | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/update.py b/update.py index 00460c2..efa4bd9 100755 --- a/update.py +++ b/update.py @@ -29,6 +29,9 @@ from agenda.types import StrDict from web_view import app +from datetime import date, timedelta + + async def update_bank_holidays(config: flask.config.Config) -> None: """Update cached copy of UK Bank holidays.""" t0 = time() @@ -318,8 +321,7 @@ def update_thespacedevs(config: flask.config.Config) -> None: """ rocket_dir = os.path.join(config["DATA_DIR"], "thespacedevs") - existing_data = agenda.thespacedevs.load_cached_launches(rocket_dir) - assert existing_data + existing_data = agenda.thespacedevs.load_cached_launches(rocket_dir) or {} if agenda.thespacedevs.is_launches_cache_fresh(rocket_dir): return @@ -411,16 +413,13 @@ def update_gandi(config: flask.config.Config) -> None: def update_weather(config: flask.config.Config) -> None: """Refresh weather cache for home and all upcoming trips.""" - from datetime import date, timedelta today = date.today() forecast_window = today + timedelta(days=8) trips = agenda.trip.build_trip_list() upcoming = [ - t - for t in trips - if (t.end or t.start) >= today and t.start <= forecast_window + t for t in trips if (t.end or t.start) >= today and t.start <= forecast_window ] seen: set[tuple[float, float]] = set()