import datetime
import logging
import os
+from typing import Any
import urllib.request
import astral # type: ignore
from astral.sun import sun # type: ignore
from bs4 import BeautifulSoup # type: ignore
+from overrides import overrides
import pytz
import argparse_utils
@persistent.persistent_autoloaded_singleton()
-class CachedDetailedWeatherForecast(object):
+class CachedDetailedWeatherForecast(persistent.Persistent):
def __init__(self, forecasts = None):
if forecasts is not None:
self.forecasts = forecasts
)
@classmethod
- def load(cls):
+ @overrides
+ def load(cls) -> Any:
if persistent.was_file_written_within_n_seconds(
config.config['weather_forecast_cachefile'],
config.config['weather_forecast_stalest_acceptable'].total_seconds(),
return cls(weather_data)
return None
- def save(self):
+ @overrides
+ def save(self) -> bool:
import pickle
with open(config.config['weather_forecast_cachefile'], 'wb') as wf:
pickle.dump(
wf,
pickle.HIGHEST_PROTOCOL,
)
+ return True