Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Simplify study_data_from_serialised() #170

Merged
merged 1 commit into from
Dec 4, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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