entity.getlist(key) fails for "no value" entries
Yorwba opened this issue · comments
Yorwba commented
Example code:
from wikidata.client import Client
client = Client()
hong_kong = client.get('Q8646')
locator_map_image = client.get('P242')
hong_kong.getlist(locator_map_image)
Error message:
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/lib/python3.6/site-packages/wikidata/entity.py", line 191, in getlist
for snak in (claim['mainsnak'] for claim in claims)]
File "/lib/python3.6/site-packages/wikidata/entity.py", line 191, in <listcomp>
for snak in (claim['mainsnak'] for claim in claims)]
KeyError: 'datavalue'
I believe that this is due to the no value entry in the list for the locator map image of Hong Kong. In this case it appears to be an error in the underlying data, but the function should handle that gracefully. Since the docstring says "Return all values associated to the given key property in sequence.", such no value entries should probably simply get ignored.