diff options
| author | Alex Schofield <git@ajschof.me> | 2026-04-27 19:27:17 +0100 |
|---|---|---|
| committer | Alex Schofield <git@ajschof.me> | 2026-04-27 19:27:17 +0100 |
| commit | 4e0035ea359a22d1d395ae731c0ae3aa2ec921a3 (patch) | |
| tree | 4e44aab4da2d6c9bd09db0f27cc7c9a44d0e464c | |
| parent | 79e8f8e76fd18a45a7f513b952261cc7d1a4fee9 (diff) | |
| download | fuelnearme-4e0035ea359a22d1d395ae731c0ae3aa2ec921a3.tar.gz fuelnearme-4e0035ea359a22d1d395ae731c0ae3aa2ec921a3.zip | |
add type hints and error handling to get_latest_data()
| -rw-r--r-- | main.py | 9 |
1 files changed, 7 insertions, 2 deletions
@@ -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") |
