Hitting T149410 again. I was trying to switch my code to use mediainfo.editEntity() instead of using site, but nothing happened.
Some example code:
import pywikibot
site = pywikibot.Site('commons', 'commons')
repo = site.data_repository()
filepage = pywikibot.FilePage(site, 'File:-2011-03-05 Southern Hill Hospital, Mundesley, Norfolk (2).jpg')
mediainfo = filepage.data_item()
new_claim = pywikibot.Claim(repo, 'P7384')
new_claim.setTarget('2295284')
data = {'claims': [new_claim.toJSON(), ]}
response = mediainfo.editEntity(data=data)
print(response)(nothing happens)
The problem is that the get API is returning 'statements' and the edit API expects 'claims'. In my dict I use claims.
This hits WikibaseEntity._normalizeData which uses these fields:
DATA_ATTRIBUTES = {
'labels': LanguageDict,
'statements': ClaimCollection,
}Claims is not in there so the data dict is empty after normalization.
I can't really think of a clean way to solve this at the moment. Maybe add ImageInfo._normalizeData() that doesn't mess it up?