Skip to content

Commit

Permalink
Merge pull request #238 from lsst-sqre/tickets/DM-42937
Browse files Browse the repository at this point in the history
DM-42937: Fix return type of parse_isodatetime
  • Loading branch information
rra authored Feb 19, 2024
2 parents d17be2a + 07d1945 commit af7611e
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 4 deletions.
3 changes: 3 additions & 0 deletions changelog.d/20240219_113514_rra_DM_42937.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
### Bug fixes

- Fix the return type of `safir.datetime.parse_isodatetime` to not include `None` since the function never returns `None`.
9 changes: 5 additions & 4 deletions src/safir/datetime.py
Original file line number Diff line number Diff line change
Expand Up @@ -111,14 +111,14 @@ def isodatetime(timestamp: datetime) -> str:
return timestamp.strftime("%Y-%m-%dT%H:%M:%SZ")


def parse_isodatetime(time_string: str) -> datetime | None:
def parse_isodatetime(time_string: str) -> datetime:
"""Parse a string in a standard ISO date format.
Parameters
----------
time_string
Date and time formatted as an ISO 8601 date and time using ``Z`` as
the time zone. This is the same format produced by `isodatetime` and
the time zone. This is the same format produced by `isodatetime` and
is compatible with Kubernetes and the IVOA UWS standard.
Returns
Expand All @@ -134,8 +134,9 @@ def parse_isodatetime(time_string: str) -> datetime | None:
Notes
-----
When parsing input for a model, use `safir.pydantic.normalize_isodatetime`
instead of this function. Using a model will be the normal case; this
function is primarily useful in tests.
instead of this function. Using a model will be the normal case; this
function is primarily useful in tests or for the special parsing cases
required by the IVOA UWS standard.
"""
if not time_string.endswith("Z"):
raise ValueError(f"{time_string} does not end with Z")
Expand Down

0 comments on commit af7611e

Please sign in to comment.