diff --git a/osf/metrics/reports.py b/osf/metrics/reports.py index cc2b4a83c22..7d37b1998c0 100644 --- a/osf/metrics/reports.py +++ b/osf/metrics/reports.py @@ -46,8 +46,10 @@ def deserialize(self, data): return YearMonth.from_str(data) elif isinstance(data, (datetime.datetime, datetime.date)): return YearMonth.from_date(data) + elif data is None: + return None else: - raise ValueError('unsure how to deserialize "{data}" (of type {type(data)}) to YearMonth') + raise ValueError(f'unsure how to deserialize "{data}" (of type {type(data)}) to YearMonth') def serialize(self, data): if isinstance(data, str): @@ -56,6 +58,8 @@ def serialize(self, data): return str(data) elif isinstance(data, (datetime.datetime, datetime.date)): return str(YearMonth.from_date(data)) + elif data is None: + return None else: raise ValueError(f'unsure how to serialize "{data}" (of type {type(data)}) as YYYY-MM')