jenkins-bot has submitted this change. ( https://gerrit.wikimedia.org/r/c/pywikibot/core/+/840276 )
Change subject: [cleanup] Remove Revision attributes deprecated with Pywikibot 4 ......................................................................
[cleanup] Remove Revision attributes deprecated with Pywikibot 4
- remove parent_id and content_model attributes - raise an AttributeError for missing outdated 'rollbacktoken' - raise an AttributeError instead of AssertionError for missing parentid - update documentation
Change-Id: I0273e8ed8739d073b11ba84f90af841ab8c8970f --- M pywikibot/page/_revision.py 1 file changed, 7 insertions(+), 38 deletions(-)
Approvals: JJMC89: Looks good to me, approved jenkins-bot: Verified
diff --git a/pywikibot/page/_revision.py b/pywikibot/page/_revision.py index e1ce8d4..0666348 100644 --- a/pywikibot/page/_revision.py +++ b/pywikibot/page/_revision.py @@ -8,8 +8,7 @@ from collections.abc import Mapping from contextlib import suppress
-from pywikibot import Timestamp, warning -from pywikibot.tools import deprecated +from pywikibot import Timestamp
class Revision(Mapping): @@ -24,6 +23,12 @@ True >>> r.comment 'Sample for Revision access' + + .. seealso:: + + - :api:`Revisions` + - :api:`Alldeletedrevisions` + """
def __init__(self, **kwargs) -> None: @@ -67,8 +72,6 @@ """Return a single Revision item given by name.""" if name in self._data: return self._data[name] - if name in ('parent_id', 'content_model'): - return getattr(self, name)
return self.__missing__(name)
@@ -89,40 +92,6 @@
def __missing__(self, key): """Provide backward compatibility for exceptions.""" - if key == 'parentid': - raise AssertionError( - 'Revision {rev.revid} was instantiated without a parent id' - .format(rev=self)) - - if key == 'rollbacktoken': - warning('"rollbacktoken" has been deprecated since MediaWiki 1.24') - return - # raise AttributeError instead of KeyError for backward compatibility raise AttributeError("'{}' object has no attribute '{}'" .format(self.__class__.__name__, key)) - - @property - @deprecated('parentid property', since='4.0.0') - def parent_id(self) -> int: - """DEPRECATED. Return id of parent/previous revision. - - Returns 0 if there is no previous revision - - :return: id of parent/previous revision - :raises AssertionError: parent id not supplied to the constructor - """ - return self.parentid - - @property - @deprecated('contentmodel', since='4.0.0') - def content_model(self) -> str: - """DEPRECATED. Return content model of the revision. - - This is meant for compatibility with older MW version which - didn't support revisions with slots. For newer MW versions, - this returns the content model of the main slot. - - :return: content model - """ - return self.contentmodel