diff --git a/swh/model/model.py b/swh/model/model.py --- a/swh/model/model.py +++ b/swh/model/model.py @@ -335,6 +335,9 @@ default=None, validator=attr.validators.optional([])) + ctime = attr.ib(type=Optional[datetime.datetime], + default=None) + @length.validator def check_length(self, attribute, value): """Checks the length is positive.""" @@ -353,8 +356,7 @@ def to_dict(self): content = attr.asdict(self) - if content['data'] is None: - del content['data'] - if content['reason'] is None: - del content['reason'] + for field in ('data', 'reason', 'ctime'): + if content[field] is None: + del content[field] return content