SuLab / WikidataIntegrator

A Wikidata Python module integrating the MediaWiki API and the Wikidata SPARQL endpoint
MIT License
244 stars 46 forks source link

Unknown datatype causes exception #142

Closed belteshassar closed 3 years ago

belteshassar commented 4 years ago

I tried WDI on the sandbox and got a weird IndexError. I removed the statement of type musical-notation, a data type that does not seem to be supported, and the exception did not trigger anymore.

There are maybe two potential fixes here:

  1. avoid exceptions when encountering unknown datatype
  2. support musical-notation datatype

Stack trace:

  File "/wikidataintegrator/wdi_core.py", line 192, in __init__
    self.init_data_load()
  File "/wikidataintegrator/wdi_core.py", line 238, in init_data_load
    self.wd_json_representation = self.get_wd_entity()
  File "/wikidataintegrator/wdi_core.py", line 299, in get_wd_entity
    return self.parse_wd_json(wd_json=json_data['entities'][self.wd_item_id])
  File "/wikidataintegrator/wdi_core.py", line 317, in parse_wd_json
    data_type = [x for x in WDBaseDataType.__subclasses__() if x.DTYPE == z['mainsnak']['datatype']][0]
IndexError: list index out of range
LeMyst commented 4 years ago

Hello @belteshassar That issue was probably resolved in MR #144 Can you check on your side? Thank you

belteshassar commented 4 years ago

Hi @Mystou I imagine it fixed the musical notation datatype, but will the same problem come back whenever Wikidata introduces a new data type?

LeMyst commented 4 years ago

Hello @belteshassar No, the problem was only because of a failed merge between two commits.