Skip to content

Commit

Permalink
lint code
Browse files Browse the repository at this point in the history
  • Loading branch information
jonhealy1 committed Apr 18, 2024
1 parent 2b47e19 commit 5a00118
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 8 deletions.
13 changes: 6 additions & 7 deletions stac_fastapi/types/stac_fastapi/types/rfc3339.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,9 +45,7 @@ def rfc3339_str_to_datetime(s: str) -> datetime:
return iso8601.parse_date(s)


def str_to_interval(
interval: Optional[str]
) -> Optional[DateTimeType]:
def str_to_interval(interval: Optional[str]) -> Optional[DateTimeType]:
"""Extract a tuple of datetimes from an interval string.
Interval strings are defined by
Expand All @@ -56,18 +54,19 @@ def str_to_interval(
or end (but not both) to be open-ended with '..' or ''.
Args:
interval (str or None): The interval string to convert to a tuple of datetime.datetime
objects, or None if no datetime is specified.
interval (str or None): The interval string to convert to a tuple of
datetime.datetime objects, or None if no datetime is specified.
Returns:
Optional[DateTimeType]: A tuple of datetime.datetime objects or None if input is None.
Optional[DateTimeType]: A tuple of datetime.datetime objects or None if
input is None.
Raises:
ValueError: If the string is not a valid interval string and not None.
"""
if interval is None:
return None

if not interval:
raise ValueError("Empty interval string is invalid.")

Expand Down
5 changes: 4 additions & 1 deletion stac_fastapi/types/tests/test_rfc3339.py
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,9 @@ def test_now_functions() -> None:

rfc3339_str_to_datetime(now_to_rfc3339_str())


def test_str_to_interval_with_none():
"""Test that str_to_interval returns None when provided with None."""
assert str_to_interval(None) is None, "str_to_interval should return None when input is None"
assert (
str_to_interval(None) is None
), "str_to_interval should return None when input is None"

0 comments on commit 5a00118

Please sign in to comment.