jenkins-bot has submitted this change. ( https://gerrit.wikimedia.org/r/c/pywikibot/core/+/981476 )
Change subject: [cleanup] remove keys() and items() methods of api.Request ......................................................................
[cleanup] remove keys() and items() methods of api.Request
- remove keys() and items() methods of api.Request because they are already inherited from MutableMapping (but as view instead a list). - deprecate iteritems() method; items should be used instead.
Bug: T310953 Change-Id: I800d6b3686d7d5fff579b0d49ff9b1a64ebc88ef --- M ROADMAP.rst M pywikibot/data/api/_requests.py 2 files changed, 26 insertions(+), 11 deletions(-)
Approvals: Xqt: Looks good to me, approved jenkins-bot: Verified
diff --git a/ROADMAP.rst b/ROADMAP.rst index 5286bd6..7535ee9 100644 --- a/ROADMAP.rst +++ b/ROADMAP.rst @@ -32,6 +32,7 @@ Deprecations ------------
+* 9.0.0: ``iteritems`` method of :class:`data.api.Request` will be removed in favour of ``items`` * 9.0.0: ``SequenceOutputter.output()`` is deprecated in favour of :attr:`tools.formatter.SequenceOutputter.out` property * 9.0.0: *nullcontext* context manager and *SimpleQueue* queue of :mod:`backports` are derecated * 8.4.0: *modules_only_mode* parameter of :class:`data.api.ParamInfo`, its *paraminfo_keys* class attribute diff --git a/pywikibot/data/api/_requests.py b/pywikibot/data/api/_requests.py index 61dad40..9cb8a99 100644 --- a/pywikibot/data/api/_requests.py +++ b/pywikibot/data/api/_requests.py @@ -38,7 +38,7 @@ ) from pywikibot.login import LoginStatus from pywikibot.textlib import removeDisabledParts, removeHTMLParts -from pywikibot.tools import PYTHON_VERSION +from pywikibot.tools import PYTHON_VERSION, deprecated
__all__ = ('CachedRequest', 'Request', 'encode_url') @@ -130,7 +130,10 @@ ['namespaces', 'userinfo']
.. versionchanged:: 8.4 - inherited from WaitingMixin. + inherited from :class:`WaitingMixin`. + + .. versionchanged:: 9.0 + *keys* and *items* methods return a view object instead a list """
# To make sure the default value of 'parameters' can be identified. @@ -382,10 +385,6 @@ """Implement dict interface.""" del self._params[key]
- def keys(self): - """Implement dict interface.""" - return list(self._params) - def __iter__(self): """Implement dict interface.""" return iter(self._params) @@ -394,13 +393,14 @@ """Implement dict interface.""" return len(self._params)
+ @deprecated('items()', since='9.0.0') def iteritems(self): - """Implement dict interface.""" - return iter(self._params.items()) + """Implement dict interface.
- def items(self): - """Return a list of tuples containing the parameters in any order.""" - return list(self._params.items()) + .. deprecated:: 9.0 + Use ``items()`` instead. + """ + return iter(self.items())
def _add_defaults(self): """
pywikibot-commits@lists.wikimedia.org