jenkins-bot submitted this change.

View Change

Approvals: Xqt: Looks good to me, approved jenkins-bot: Verified
[6.0] Remove get_redirects from APISite.search() method

Only mw 1.23+ is supported with Pywikibot 6.0.

- remove obsolete get_redirects parameter from APISite.search() method
- require keyword arguments for all parameters except searchstring

Bug: T268979
Change-Id: I2d48bdd051f3a44e3636551a682f79e421e7c146
---
M pywikibot/site/_apisite.py
M tests/site_tests.py
2 files changed, 8 insertions(+), 10 deletions(-)

diff --git a/pywikibot/site/_apisite.py b/pywikibot/site/_apisite.py
index 698d10b..9a9c922 100644
--- a/pywikibot/site/_apisite.py
+++ b/pywikibot/site/_apisite.py
@@ -2811,9 +2811,12 @@
return rcgen

@deprecated_args(number='total', step=None, key='searchstring',
- getredirects='get_redirects')
- def search(self, searchstring: str, namespaces=None, where='text',
- get_redirects=False, total=None, content=False):
+ getredirects=True, get_redirects=None)
+ def search(self, searchstring: str, *,
+ namespaces=None,
+ where: str = 'text',
+ total: Optional[int] = None,
+ content: bool = False):
"""Iterate Pages that contain the searchstring.

Note that this may include non-existing Pages if the wiki's database
@@ -2828,8 +2831,6 @@
@type namespaces: iterable of str or Namespace key,
or a single instance of those types. May be a '|' separated
list of namespace identifiers.
- @param get_redirects: if True, include redirects in results. Since
- version MediaWiki 1.23 it will always return redirects.
@param content: if True, load the current content of each iterated page
(default False)
@raises KeyError: a namespace identifier was not resolved
@@ -2863,8 +2864,6 @@
gsrsearch=searchstring, gsrwhat=where,
namespaces=namespaces,
total=total, g_content=content)
- if self.mw_version < '1.23':
- srgen.request['gsrredirects'] = get_redirects
return srgen

@deprecated_args(step=None, showMinor='minor')
diff --git a/tests/site_tests.py b/tests/site_tests.py
index 2d4c74c..1960645 100644
--- a/tests/site_tests.py
+++ b/tests/site_tests.py
@@ -1445,8 +1445,7 @@
for hit in mysite.search('another', namespaces='8|9|10', total=5):
self.assertIsInstance(hit, pywikibot.Page)
self.assertIn(hit.namespace(), [8, 9, 10])
- for hit in mysite.search('wiki', namespaces=0, total=10,
- get_redirects=True):
+ for hit in mysite.search('wiki', namespaces=0, total=10):
self.assertIsInstance(hit, pywikibot.Page)
self.assertEqual(hit.namespace(), 0)
except pywikibot.data.api.APIError as e:
@@ -1461,7 +1460,7 @@
def test_search_where_title(self):
"""Test site.search() method with 'where' parameter set to title."""
search_gen = self.site.search(
- 'wiki', namespaces=0, total=10, get_redirects=True, where='title')
+ 'wiki', namespaces=0, total=10, where='title')
expected_params = {
'prop': ['info', 'imageinfo', 'categoryinfo'],
'inprop': ['protection'],

To view, visit change 672350. To unsubscribe, or for help writing mail filters, visit settings.

Gerrit-Project: pywikibot/core
Gerrit-Branch: master
Gerrit-Change-Id: I2d48bdd051f3a44e3636551a682f79e421e7c146
Gerrit-Change-Number: 672350
Gerrit-PatchSet: 2
Gerrit-Owner: Xqt <info@gno.de>
Gerrit-Reviewer: Xqt <info@gno.de>
Gerrit-Reviewer: jenkins-bot
Gerrit-MessageType: merged