Xqt has submitted this change. (
https://gerrit.wikimedia.org/r/c/pywikibot/core/+/1121771?usp=email )
Change subject: [IMPR] no longer pass continue= as with api query in
QueryGenerator
......................................................................
[IMPR] no longer pass continue= as with api query in QueryGenerator
- the 'continue' parameter can be omitted in mw >= 1.26
- update documentation for APIGenerator and CachedRequest
Bug: T343204
Change-Id: Iace6f15ab63c3f0b753483ca9cd1230a9bbc9b5c
---
M pywikibot/data/api/_generators.py
M pywikibot/data/api/_requests.py
M tests/site_generators_tests.py
3 files changed, 15 insertions(+), 8 deletions(-)
Approvals:
Xqt: Verified; Looks good to me, approved
diff --git a/pywikibot/data/api/_generators.py
b/pywikibot/data/api/_generators.py
index 776dbeb..2e89f36 100644
--- a/pywikibot/data/api/_generators.py
+++ b/pywikibot/data/api/_generators.py
@@ -103,6 +103,12 @@
:param continue_name: Name of the continue API parameter.
:param limit_name: Name of the limit API parameter.
:param data_name: Name of the data in API response.
+ :keyword dict parameters: All parameters passed to request class
+ usally :class:`api.Request<data.api.Request>` or
+ :class:`api.CachedRequest<data.api.CachedRequest>`. See these
+ classes for further parameter descriptions. The *parameters*
+ keys can also given here as keyword parameters but this is
+ not recommended.
"""
kwargs = self._clean_kwargs(kwargs, action=action)
@@ -243,8 +249,6 @@
parameters['indexpageids'] = True # always ask for list of pageids
self.continue_name = 'continue'
- # Explicitly enable the simplified continuation
- parameters['continue'] = True
self.request = self.request_class(**kwargs)
self.site._paraminfo.fetch('query+' + mod for mod in self.modules)
@@ -494,8 +498,8 @@
.. versionchanged:: 8.4
return *None* instead of *False*.
"""
- for key, value in self.data['continue'].items():
- # query-continue can return ints (continue too?)
+ for key, value in self.data[self.continue_name].items():
+ # old query-continue could return ints, continue too?
if isinstance(value, int):
value = str(value)
self.request[key] = value
diff --git a/pywikibot/data/api/_requests.py b/pywikibot/data/api/_requests.py
index 5a0bc9b..b1d5737 100644
--- a/pywikibot/data/api/_requests.py
+++ b/pywikibot/data/api/_requests.py
@@ -1,6 +1,6 @@
"""Objects representing API requests."""
#
-# (C) Pywikibot team, 2007-2024
+# (C) Pywikibot team, 2007-2025
#
# Distributed under the terms of the MIT license.
#
@@ -146,7 +146,8 @@
max_retries: int | None = None,
retry_wait: int | None = None,
use_get: bool | None = None,
- parameters=_PARAM_DEFAULT, **kwargs) -> None:
+ parameters=_PARAM_DEFAULT,
+ **kwargs) -> None:
"""Create a new Request instance with the given parameters.
The parameters for the request can be defined via either the
@@ -1163,7 +1164,10 @@
def __init__(self, expiry, *args, **kwargs) -> None:
"""Initialize a CachedRequest object.
- :param expiry: either a number of days or a datetime.timedelta object
+ :param expiry: either a number of days or a datetime.timedelta
+ object
+ :param args: Refer :class:`Request` for positional arguments.
+ :param args: Refer :class:`Request` for keyword arguments.
"""
assert expiry is not None
super().__init__(*args, **kwargs)
diff --git a/tests/site_generators_tests.py b/tests/site_generators_tests.py
index 4100026..c16c219 100755
--- a/tests/site_generators_tests.py
+++ b/tests/site_generators_tests.py
@@ -28,7 +28,6 @@
global_expected_params = {
'action': ['query'],
- 'continue': [True],
'iilimit': ['max'],
'iiprop': list(pywikibot.site._IIPROP),
'indexpageids': [True],
--
To view, visit
https://gerrit.wikimedia.org/r/c/pywikibot/core/+/1121771?usp=email
To unsubscribe, or for help writing mail filters, visit
https://gerrit.wikimedia.org/r/settings?usp=email
Gerrit-MessageType: merged
Gerrit-Project: pywikibot/core
Gerrit-Branch: master
Gerrit-Change-Id: Iace6f15ab63c3f0b753483ca9cd1230a9bbc9b5c
Gerrit-Change-Number: 1121771
Gerrit-PatchSet: 2
Gerrit-Owner: Xqt <[email protected]>
Gerrit-Reviewer: Xqt <[email protected]>
Gerrit-Reviewer: jenkins-bot
_______________________________________________
Pywikibot-commits mailing list -- [email protected]
To unsubscribe send an email to [email protected]