aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAlex Schofield <git@ajschof.me>2026-04-27 19:27:17 +0100
committerAlex Schofield <git@ajschof.me>2026-04-27 19:27:17 +0100
commit4e0035ea359a22d1d395ae731c0ae3aa2ec921a3 (patch)
tree4e44aab4da2d6c9bd09db0f27cc7c9a44d0e464c
parent79e8f8e76fd18a45a7f513b952261cc7d1a4fee9 (diff)
downloadfuelnearme-4e0035ea359a22d1d395ae731c0ae3aa2ec921a3.tar.gz
fuelnearme-4e0035ea359a22d1d395ae731c0ae3aa2ec921a3.zip
add type hints and error handling to get_latest_data()
-rw-r--r--main.py9
1 files changed, 7 insertions, 2 deletions
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")
git.ajschof.me — hosted by ajschofield — powered by cgit