In T95168 the Wikidata api is slightly changed. In the old format if an item doesn't have claims, you won't see claim in the api. In the new format will return '"claims": {}' as part of the output. Same goes for descriptions, aliases and sitelinks. More info at https://www.wikidata.org/wiki/User:Addshore/API_Break_September_2015 . We just need to make sure pywikibot can work with both formats.
Description
Details
| Subject | Repo | Branch | Lines +/- | |
|---|---|---|---|---|
| DataSite.get_entity | pywikibot/core | master | +49 -39 |
| Status | Subtype | Assigned | Task | ||
|---|---|---|---|---|---|
| Resolved | jayvdb | T110559 Make sure that Pywikibot still works with new api data output format | |||
| Resolved | Addshore | T95168 [Task] Remove calls to getIsRawMode() in Wikibase, and calls to setRawMode() in tests | |||
| Resolved | Addshore | T110668 PropertyId is not formatted with label when saving / adding new statements |
Event Timeline
I don't think this is going to be a problem as pywikibot.page.WikibasePage.get is defining an empty dict and then checking if that dict is in the returned data to then just iterate over it: https://phabricator.wikimedia.org/diffusion/PWBC/browse/master/pywikibot/page.py;51f7a894d15e5883053e13de03f14d2f2b46abdf$3306
wbgetentities was returning a entities dict. It is now a list.
https://www.wikidata.org/w/api.php?action=wbgetentities&ids=Q943
{
"entities": {
"Q943": {
"pageid": 1827,
"ns": 0,
"title": "Q943",
...https://test.wikidata.org/w/api.php?action=wbgetentities&ids=Q943
{
"entities": [
{
"pageid": 1827,
"ns": 0,
"title": "Q943",
...The fix for T110668 doesnt appear to solve the problem of dict->list for entities.
The 'after' in https://www.wikidata.org/wiki/User:Addshore/API_Break_September_2015#Sample_JSON_changes doesnt show entities has changed to a list. :/
Change 237004 had a related patch set uploaded (by John Vandenberg):
Support new Wikibase entities
https://gerrit.wikimedia.org/r/237028
Unfortunately the JSON format is poorly tested, so it's going to break again sooner or later.
this might be a bug in wikibase and not intentional. (regarding entities as a dict)
need to poke addshore and see if this is something we can fix quickly
This will be fixed for the release, the keys will be there.
Our API output does have good test coverage, just apparently not of these keys...
As a follow up I will add a JSON integration test for getentities
With the test not failing anymore and the patches have be merged (both request from @jayvdb's post T110559#1618721 have the same structure now) I don't think we'll be further affected by that change.