From 4e0035ea359a22d1d395ae731c0ae3aa2ec921a3 Mon Sep 17 00:00:00 2001 From: Alex Schofield Date: Mon, 27 Apr 2026 19:27:17 +0100 Subject: add type hints and error handling to get_latest_data() --- main.py | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) (limited to 'main.py') diff --git a/main.py b/main.py index ae842f4..d601c6b 100644 --- a/main.py +++ b/main.py @@ -2,6 +2,7 @@ import argparse import sys from io import StringIO from textwrap import dedent +from typing import Tuple import pandas as pd import requests @@ -37,8 +38,12 @@ def get_location(address: str) -> tuple[float, float]: return (result.latitude, result.longitude) -def get_latest_data(): - response = requests.get(ENDPOINT) +def get_latest_data() -> Tuple[pd.DataFrame, str]: + try: + response = requests.get(ENDPOINT) + response.raise_for_status() + except Exception as e: + raise e return pd.read_csv(StringIO(response.text)), response.headers.get("Last-Modified") -- cgit v1.2.3