Please treat this as an RFC rather than a bug report. The following simplified code should illustrate the problem:
val = pywikibot.FilePage(commons, filename) while val.isRedirectPage(): val = val.getRedirectTarget() #type(val) is now pywikibot.Page claim = pywikibot.Claim(self.item.repo, prop, datatype="commonsMedia") claim.setTarget(val) #this fails if filename is redirect, works otherwise
Even if theoretically you could have cross-ns redirects, these are highly discouraged and so I believe it would make sense to override getRedirectTarget in FilePage to ensure it returns a FilePage rather than a simple Page.