forked from edward/owl-map
Type hints and docstrings.
This commit is contained in:
parent
212a4f4ec3
commit
0ed3d3c761
|
@ -107,7 +107,7 @@ class Item(Base):
|
||||||
|
|
||||||
def get_claim(self, pid: str) -> list[dict[str, Any] | None]:
|
def get_claim(self, pid: str) -> list[dict[str, Any] | None]:
|
||||||
"""List of claims for given Wikidata property ID."""
|
"""List of claims for given Wikidata property ID."""
|
||||||
claims = typing.cast(dict[str, list[dict[str, Any]]], self.claims)
|
claims = typing.cast(wikidata.Claims, self.claims)
|
||||||
return [
|
return [
|
||||||
i["mainsnak"]["datavalue"]["value"]
|
i["mainsnak"]["datavalue"]["value"]
|
||||||
if "datavalue" in i["mainsnak"]
|
if "datavalue" in i["mainsnak"]
|
||||||
|
@ -221,10 +221,12 @@ class Item(Base):
|
||||||
|
|
||||||
return dict(d) or None
|
return dict(d) or None
|
||||||
|
|
||||||
def get_isa(self):
|
def get_isa(self) -> list[dict[str, int | str]]:
|
||||||
|
"""Get item IDs of IsA items for this item."""
|
||||||
isa_list = []
|
isa_list = []
|
||||||
of_property = "P642"
|
of_property = "P642"
|
||||||
for claim in self.claims.get("P31", []):
|
claims = typing.cast(wikidata.Claims, self.claims)
|
||||||
|
for claim in claims.get("P31", []):
|
||||||
qualifiers = claim.get("qualifiers", {})
|
qualifiers = claim.get("qualifiers", {})
|
||||||
if "datavalue" in claim["mainsnak"]:
|
if "datavalue" in claim["mainsnak"]:
|
||||||
isa_list.append(claim["mainsnak"]["datavalue"]["value"])
|
isa_list.append(claim["mainsnak"]["datavalue"]["value"])
|
||||||
|
|
Loading…
Reference in a new issue