jenkins-bot has submitted this change. ( https://gerrit.wikimedia.org/r/c/pywikibot/core/+/910813 )
Change subject: [IMPR] Ensure that _cmpkey method is defined in subclasses of ComparableMixin ...................................................................... [IMPR] Ensure that _cmpkey method is defined in subclasses of ComparableMixin Change-Id: I91921c8f4548de62b834e223865f23a05ce63117 --- M pywikibot/tools/__init__.py 1 file changed, 21 insertions(+), 2 deletions(-) Approvals: Matěj Suchánek: Looks good to me, approved jenkins-bot: Verified diff --git a/pywikibot/tools/__init__.py b/pywikibot/tools/__init__.py index 1c06290..023b922 100644 --- a/pywikibot/tools/__init__.py +++ b/pywikibot/tools/__init__.py @@ -1,9 +1,10 @@ """Miscellaneous helper functions (not wiki-dependent).""" # -# (C) Pywikibot team, 2008-2022 +# (C) Pywikibot team, 2008-2023 # # Distributed under the terms of the MIT license. # +import abc import bz2 import gzip import hashlib @@ -226,13 +227,22 @@ # From http://python3porting.com/preparing.html -class ComparableMixin: +class ComparableMixin(abc.ABC): """Mixin class to allow comparing to other objects which are comparable. .. versionadded:: 3.0 """ + @abc.abstractmethod + def _cmpkey(self) -> Any: + """Abstract method to return key for comparison of objects. + + This ensures that ``_cmpkey`` method is defined in subclass. + + .. versionadded:: 8.2 + """ + def __lt__(self, other): """Compare if self is less than other.""" return other > self._cmpkey() -- To view, visit https://gerrit.wikimedia.org/r/c/pywikibot/core/+/910813 To unsubscribe, or for help writing mail filters, visit https://gerrit.wikimedia.org/r/settings Gerrit-Project: pywikibot/core Gerrit-Branch: master Gerrit-Change-Id: I91921c8f4548de62b834e223865f23a05ce63117 Gerrit-Change-Number: 910813 Gerrit-PatchSet: 2 Gerrit-Owner: Xqt <i...@gno.de> Gerrit-Reviewer: Matěj Suchánek <matejsuchane...@gmail.com> Gerrit-Reviewer: jenkins-bot Gerrit-MessageType: merged
_______________________________________________ Pywikibot-commits mailing list -- pywikibot-commits@lists.wikimedia.org To unsubscribe send an email to pywikibot-commits-le...@lists.wikimedia.org