| Lokal_Profil added a comment. |
Expanding on my previous comment about the current and proposed pywikibot.Claim being a mixture of Wikibase's Claim and Statement. Reproducing that structure in pywikibot would be fairly easy using the below amendment to the proposal
class Claim(BaseClaim):
def __init__(): '''Attributes''' self.rank = 'normal' self.qualifiers = OrderedDict() def getRank def setRank def changeRank def addQualifier def removeQualifier def removeQualifiers def has_qualifier class Statement(object): def __init__(): '''Attributes''' self.claim = None self.references = [] def getSources def addSource def addSources def removeSource def removeSources
BUT other than reducing some confusion and being able to make sensible Claim comparison (comparing should ignore sources) the benefits don't outweigh the benefits of having them in one object. I would however propose naming it Statement(BaseClaim) or StatementClaim(BaseClaim) to avoid confusion. This would also be a clean break alowing us to temporarily raise an Error if anyone calls Claim. I also think this is something we want to do for Lexeme support in the future where there are yet other types of claims.
I noticed that the snak, hash and on_item attributes have been dropped. Is this on purpose? Are they not currently needed?
For the equality issue I would propose adding something like the following method to the Statement/StatementClaim class
def same_as(target, ignore_rank=True, ignore_refs=True, ignore_quals=False, ignore_qual_order=False): # order of self.references is always ignored def __eq__(target): return self.same_as(target, False, False)
It might also be useful to default to ignoring the order of ReferenceGroup.references for comparisons.
Lastly to reiterate that with the above caveat about renaming (and dumping targetEquals) I fully support the much needed refactoring.
Cc: Dvorapa, Lokal_Profil, Aklapper, matej_suchanek, pywikibot-bugs-list, Sc4s2cg, Magul, Tbscho, MayS, Framawiki, Salgo60, Mdupont, JJMC89, Avicennasis, jayvdb, Ricordisamoa, Dalba, Masti, Alchimista, Rxy
_______________________________________________ pywikibot-bugs mailing list [email protected] https://lists.wikimedia.org/mailman/listinfo/pywikibot-bugs
