jenkins-bot has submitted this change and it was merged. Change subject: Request: warn if site not provided ......................................................................
Request: warn if site not provided Add explicit site param for Request invocations Bug: T77965 Change-Id: I5d6b76dac1dfdafc212b271d4b964885569163b8 --- M pywikibot/data/api.py M pywikibot/page.py M pywikibot/site.py M scripts/casechecker.py M scripts/redirect.py M scripts/watchlist.py M tests/page_tests.py 7 files changed, 9 insertions(+), 10 deletions(-) Approvals: XZise: Looks good to me, approved jenkins-bot: Verified diff --git a/pywikibot/data/api.py b/pywikibot/data/api.py index 98c8b73..1171473 100644 --- a/pywikibot/data/api.py +++ b/pywikibot/data/api.py @@ -1105,6 +1105,7 @@ self.site = kwargs.pop("site") except KeyError: self.site = pywikibot.Site() + warn('Request() invoked without a site', RuntimeWarning, 2) if 'mime_params' in kwargs: self.mime_params = kwargs.pop('mime_params') # mime may not be different from mime_params diff --git a/pywikibot/page.py b/pywikibot/page.py index 8d17dc7..c724519 100644 --- a/pywikibot/page.py +++ b/pywikibot/page.py @@ -2819,7 +2819,7 @@ } if ccme: params['ccme'] = 1 - mailrequest = pywikibot.data.api.Request(**params) + mailrequest = pywikibot.data.api.Request(site=self.site, **params) maildata = mailrequest.submit() if 'error' in maildata: diff --git a/pywikibot/site.py b/pywikibot/site.py index bbac719..7f25aea 100644 --- a/pywikibot/site.py +++ b/pywikibot/site.py @@ -4734,6 +4734,7 @@ data = req.submit() return data + @must_be(group='user') def watchpage(self, page, unwatch=False): """Add or remove page from watchlist. @@ -4743,7 +4744,7 @@ """ token = self.tokens['watch'] - req = api.Request(action="watch", token=token, + req = api.Request(site=self, action='watch', token=token, title=page.title(withSection=False), unwatch=unwatch) result = req.submit() if "watch" not in result: diff --git a/scripts/casechecker.py b/scripts/casechecker.py index b4b608b..e7aff0a 100755 --- a/scripts/casechecker.py +++ b/scripts/casechecker.py @@ -267,7 +267,7 @@ 'pllimit': 'max', } - req = api.Request(**wlparams) + req = api.Request(site=self.site, **wlparams) data = req.submit() if len(data['query']['pageids']) == 1: pageid = data['query']['pageids'][0] diff --git a/scripts/redirect.py b/scripts/redirect.py index 2dcaa34..e007146 100755 --- a/scripts/redirect.py +++ b/scripts/redirect.py @@ -226,8 +226,8 @@ where chain or loop detecton was halted, or None if unknown """ for apiQ in self._next_redirect_group(): - gen = pywikibot.data.api.Request(action="query", redirects="", - pageids=apiQ) + gen = pywikibot.data.api.Request(site=self.site, action='query', + redirects=True, pageids=apiQ) data = gen.submit() if 'error' in data: raise RuntimeError("API query error: %s" % data) diff --git a/scripts/watchlist.py b/scripts/watchlist.py index 62770b4..f3a0a76 100755 --- a/scripts/watchlist.py +++ b/scripts/watchlist.py @@ -64,7 +64,6 @@ params = { 'action': 'query', 'list': 'watchlistraw', - 'site': site, 'wrlimit': config.special_page_limit, } @@ -72,7 +71,7 @@ # pywikibot.put_throttle() # It actually is a get, but a heavy one. watchlist = [] while True: - req = CachedRequest(config.API_config_expiry, **params) + req = CachedRequest(config.API_config_expiry, site=site, **params) data = req.submit() if 'error' in data: raise RuntimeError('ERROR: %s' % data) diff --git a/tests/page_tests.py b/tests/page_tests.py index 1ce104f..202189f 100644 --- a/tests/page_tests.py +++ b/tests/page_tests.py @@ -16,7 +16,7 @@ import pywikibot.page from tests.aspects import unittest, TestCase, DefaultSiteTestCase -from tests.utils import allowed_failure, expected_failure_if +from tests.utils import expected_failure_if if sys.version_info[0] > 2: basestring = (str, ) @@ -755,12 +755,10 @@ mainpage = self.get_mainpage() self.assertIsInstance(mainpage.purge(), bool) - @allowed_failure def test_watch(self): """Test Page.watch, with and without unwatch enabled.""" # Note: this test uses the userpage, so that it is unwatched and # therefore is not listed by script_tests test_watchlist_simulate. - # FIXME: T77965: fails on ar.wp and test.wd, but not en.wp and fr.wikt userpage = self.get_userpage() rv = userpage.watch() self.assertIsInstance(rv, bool) -- To view, visit https://gerrit.wikimedia.org/r/209467 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: merged Gerrit-Change-Id: I5d6b76dac1dfdafc212b271d4b964885569163b8 Gerrit-PatchSet: 2 Gerrit-Project: pywikibot/core Gerrit-Branch: master Gerrit-Owner: John Vandenberg <jay...@gmail.com> Gerrit-Reviewer: John Vandenberg <jay...@gmail.com> Gerrit-Reviewer: Ladsgroup <ladsgr...@gmail.com> Gerrit-Reviewer: Merlijn van Deen <valhall...@arctus.nl> Gerrit-Reviewer: XZise <commodorefabia...@gmx.de> Gerrit-Reviewer: jenkins-bot <> _______________________________________________ Pywikibot-commits mailing list Pywikibot-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/pywikibot-commits