Page Menu
Home
Software Heritage
Search
Configure Global Search
Log In
Paste
P695
negative_utc tristate
Active
Public
Actions
Authored by
olasd
on Jun 12 2020, 12:42 PM.
Edit Paste
Archive Paste
View Raw File
Subscribe
Mute Notifications
Award Token
Flag For Later
Tags
None
Subscribers
None
modified swh/model/model.py
@@ -175,7 +175,7 @@ class TimestampWithTimezone(BaseModel):
timestamp = attr.ib(type=Timestamp, validator=type_validator())
offset = attr.ib(type=int, validator=type_validator())
- negative_utc = attr.ib(type=bool, validator=type_validator())
+ negative_utc = attr.ib(type=Optional[bool], validator=type_validator())
@offset.validator
def check_offset(self, attribute, value):
@@ -188,8 +188,10 @@ class TimestampWithTimezone(BaseModel):
@negative_utc.validator
def check_negative_utc(self, attribute, value):
+ if value is None and self.offset == 0:
+ raise ValueError("negative_utc can only be unset when offset != 0")
if self.offset and value:
- raise ValueError("negative_utc can only be True is offset=0")
+ raise ValueError("negative_utc can only be True when offset == 0")
@classmethod
def from_dict(cls, obj: Union[Dict, datetime.datetime, int]):
Event Timeline
olasd
created this paste.
Jun 12 2020, 12:42 PM
2020-06-12 12:42:27 (UTC+2)
Log In to Comment