Skip to content

Commit

Permalink
Simplify study_data_from_serialised() (#170)
Browse files Browse the repository at this point in the history
Remove the `except()` block, which is already implicitly called.
From production PIXL (SAFEHR-data/the-rolling-skeleton#126)
  • Loading branch information
milanmlft authored Dec 4, 2023
1 parent 2471758 commit fb28614
Showing 1 changed file with 5 additions and 10 deletions.
15 changes: 5 additions & 10 deletions cli/src/pixl_cli/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -423,13 +423,8 @@ def api_config_for_queue(queue_name: str) -> APIConfig:

def study_date_from_serialised(message: bytes) -> datetime.datetime:
"""Get the study date from a serialised message as a datetime"""
try:
result = deserialise(message)["study_datetime"]
if not isinstance(result, datetime.datetime):
msg = "Expected study date to be a datetime. Got %s"
raise TypeError(msg, type(result))
except (AssertionError, KeyError) as exc:
msg = "Failed to get the study date from the message"
raise AssertionError(msg) from exc
else:
return result
result = deserialise(message)["study_datetime"]
if not isinstance(result, datetime.datetime):
msg = "Expected study date to be a datetime. Got %s"
raise TypeError(msg, type(result))
return result

0 comments on commit fb28614

Please sign in to comment.