Handle missing value for P571 property

This commit is contained in:
Edward Betts 2023-11-09 07:39:02 +01:00
parent ae0b2e5a51
commit 00773cd5f9

View file

@ -112,8 +112,10 @@ class Item(Base):
@property
def date(self) -> str | None:
v = wikibase.first_datavalue(typing.cast(Entity, self.entity), "P571")
if not v:
return None
assert isinstance(v, dict)
return utils.format_time(v["time"], v["precision"]) if v else None
return utils.format_time(v["time"], v["precision"])
class Triple(Base):