Skip to content

Commit

Permalink
fix join-url function import and handle unexpected input (#124)
Browse files Browse the repository at this point in the history
  • Loading branch information
br-g authored Nov 10, 2024
1 parent 7a10df9 commit a05ba21
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 4 deletions.
2 changes: 1 addition & 1 deletion src/openf1/services/ingestor_livetiming/historical/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
from openf1.services.ingestor_livetiming.core.processing.main import process_messages
from openf1.util import join_url
from openf1.util.db import DbBatchIngestor
from openf1.util.misc import json_serializer, to_datetime, to_timedelta
from openf1.util.misc import join_url, json_serializer, to_datetime, to_timedelta
from openf1.util.schedule import get_meeting_keys
from openf1.util.schedule import get_schedule as _get_schedule
from openf1.util.schedule import get_session_keys
Expand Down
6 changes: 4 additions & 2 deletions src/openf1/util/misc.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,10 @@

def join_url(*args) -> str:
"""Join URL parts with a forward slash"""
return "/".join([e.strip("/") for e in args if e is not None and
e.strip("/") != ""])
if any(len(e) == 0 or e is None for e in args):
raise ValueError(f"Invalid URL components: {args}")
return "/".join([e.strip("/") for e in args])


def timed_cache(expiration_time: float) -> Callable:
"""A decorator to cache the function output for a given duration.
Expand Down
2 changes: 1 addition & 1 deletion src/openf1/util/schedule.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import json
import os
from functools import lru_cache

import requests

from openf1.util import join_url
from openf1.util.db import get_latest_session_info
from openf1.util.misc import join_url


@lru_cache()
Expand Down

0 comments on commit a05ba21

Please sign in to comment.