jenkins-bot has submitted this change. ( https://gerrit.wikimedia.org/r/c/pywikibot/core/+/876354 )
Change subject: [bugfix] Fix Claim.__repr__ for stub instances ......................................................................
[bugfix] Fix Claim.__repr__ for stub instances
Bug: T326453 Change-Id: Ib48870a8c4f9f24416f9843fd59d35230a9fdf64 --- M pywikibot/page/_wikibase.py 1 file changed, 15 insertions(+), 2 deletions(-)
Approvals: Xqt: Looks good to me, approved jenkins-bot: Verified
diff --git a/pywikibot/page/_wikibase.py b/pywikibot/page/_wikibase.py index a8640d6..405af2b 100644 --- a/pywikibot/page/_wikibase.py +++ b/pywikibot/page/_wikibase.py @@ -1458,8 +1458,11 @@
def __repr__(self) -> str: """Return the representation string.""" - return '{cls_name}.fromJSON({}, {})'.format( - repr(self.repo), self.toJSON(), cls_name=type(self).__name__) + cls_name = type(self).__name__ + if self.target: + return f'{cls_name}.fromJSON({self.repo!r}, {self.toJSON()})' + else: + return f'{cls_name}({self.repo!r}, {self.id!r})'
def __eq__(self, other): if not isinstance(other, self.__class__):
pywikibot-commits@lists.wikimedia.org