jenkins-bot has submitted this change. ( https://gerrit.wikimedia.org/r/c/pywikibot/core/+/690553 )
Change subject: [IMPR] Avoid redefining of builtin functions ......................................................................
[IMPR] Avoid redefining of builtin functions
Change-Id: Ie8794d209d41d2a911694fe7e1f85b2dd896a4f6 --- M pywikibot/page/__init__.py M scripts/templatecount.py M tests/deletionbot_tests.py M tests/site_detect_tests.py 4 files changed, 19 insertions(+), 13 deletions(-)
Approvals: JJMC89: Looks good to me, approved jenkins-bot: Verified
diff --git a/pywikibot/page/__init__.py b/pywikibot/page/__init__.py index 9cdaa25..390e23a 100644 --- a/pywikibot/page/__init__.py +++ b/pywikibot/page/__init__.py @@ -1702,11 +1702,12 @@ movetalk=movetalk, noredirect=noredirect)
+ @deprecate_arg('quit', 'automatic_quit') def delete(self, reason: Optional[str] = None, prompt: bool = True, mark: bool = False, - quit: bool = False): + automatic_quit: bool = False): """ Delete the page from the wiki. Requires administrator status.
@@ -1716,7 +1717,8 @@ @param mark: If true, and user does not have sysop rights, place a speedy-deletion request on the page instead. If false, non-sysops will be asked before marking pages for deletion. - @param quit: show also the quit option, when asking for confirmation. + @param automatic_quit: show also the quit option, when asking + for confirmation. """ if reason is None: pywikibot.output('Deleting {}.'.format(self.title(as_link=True))) @@ -1730,7 +1732,7 @@ 'Do you want to delete {}?'.format(self.title( as_link=True, force_interwiki=True)), [('Yes', 'y'), ('No', 'n'), ('All', 'a')], - 'n', automatic_quit=quit) + 'n', automatic_quit=automatic_quit) if answer == 'a': answer = 'y' self.site._noDeletePrompt = True diff --git a/scripts/templatecount.py b/scripts/templatecount.py index 0aff7fd4f..fb1e03e 100755 --- a/scripts/templatecount.py +++ b/scripts/templatecount.py @@ -33,7 +33,7 @@
""" # -# (C) Pywikibot team, 2006-2020 +# (C) Pywikibot team, 2006-2021 # # Distributed under the terms of the MIT license. # @@ -61,16 +61,16 @@ @param namespaces: list of namespace numbers @type namespaces: list """ - format = '{0:<10}: {1:>5}' + formatstr = '{0:<10}: {1:>5}' template_dict = cls.template_dict(templates, namespaces) pywikibot.stdout('\nNumber of transclusions per template') pywikibot.stdout('-' * 36) total = 0 for key in template_dict: count = len(template_dict[key]) - pywikibot.stdout(format.format(key, count)) + pywikibot.stdout(formatstr.format(key, count)) total += count - pywikibot.stdout(format.format('TOTAL', total)) + pywikibot.stdout(formatstr.format('TOTAL', total)) pywikibot.stdout('Report generated on {}' .format(datetime.datetime.utcnow().isoformat()))
diff --git a/tests/deletionbot_tests.py b/tests/deletionbot_tests.py index e985b7c..2e08ace 100644 --- a/tests/deletionbot_tests.py +++ b/tests/deletionbot_tests.py @@ -111,10 +111,10 @@ self.assertEqual(self.undelete_args, ['[[FoooOoOooO]]', 'foo'])
-def delete_dummy(self, reason, prompt, mark, quit): +def delete_dummy(self, reason, prompt, mark, automatic_quit): """Dummy delete method.""" TestDeletionBot.delete_args = [self.title(as_link=True), reason, prompt, - mark, quit] + mark, automatic_quit]
def undelete_dummy(self, reason): diff --git a/tests/site_detect_tests.py b/tests/site_detect_tests.py index f7e266d..cd16cf9 100644 --- a/tests/site_detect_tests.py +++ b/tests/site_detect_tests.py @@ -9,7 +9,7 @@ from http import HTTPStatus from urllib.parse import urlparse
-from requests.exceptions import ConnectionError, Timeout, TooManyRedirects +import requests.exceptions as requests_exceptions
import pywikibot from pywikibot.exceptions import ServerError @@ -34,7 +34,7 @@ """ try: self.assertIsInstance(MWSite(url), MWSite) - except (ServerError, Timeout) as e: + except (ServerError, requests_exceptions.Timeout) as e: self.skipTest(e)
def assertNoSite(self, url: str): @@ -44,8 +44,12 @@ @param url: Url of tested site @raises AssertionError: Site under url is MediaWiki powered """ - with self.assertRaises((AttributeError, ConnectionError, RuntimeError, - ServerError, Timeout, TooManyRedirects)) as e: + with self.assertRaises((AttributeError, + RuntimeError, + ServerError, + requests_exceptions.ConnectionError, + requests_exceptions.Timeout, + requests_exceptions.TooManyRedirects)) as e: MWSite(url) unittest_print('\nassertNoSite expected exception:\n{e!r}' .format(e=e.exception))
pywikibot-commits@lists.wikimedia.org