jenkins-bot has submitted this change. ( https://gerrit.wikimedia.org/r/c/pywikibot/core/+/639638 )
Change subject: [IMPR] Rewrite pywikibot scripts to support Python 3.5+ only ......................................................................
[IMPR] Rewrite pywikibot scripts to support Python 3.5+ only
Bug: T257399 Change-Id: I73ba043bc11e1d0725b6b9db36b8171ce36cff27 --- M scripts/followlive.py M scripts/freebasemappingupload.py M scripts/image.py M scripts/imagerecat.py M scripts/lonelypages.py M scripts/makecat.py M scripts/selflink.py 7 files changed, 22 insertions(+), 35 deletions(-)
Approvals: Xqt: Looks good to me, approved jenkins-bot: Verified
diff --git a/scripts/followlive.py b/scripts/followlive.py index 9d9fe2b..5413879 100644 --- a/scripts/followlive.py +++ b/scripts/followlive.py @@ -19,8 +19,6 @@ # # Distributed under the terms of the MIT license. # -from __future__ import absolute_import, division, unicode_literals - import datetime
import pywikibot @@ -435,7 +433,7 @@ q) quit cleaningbot Enter) OK What is it? """ - super(CleaningBot, self).__init__(**kwargs) + super().__init__(**kwargs) self.generator = self.site.newpages()
def show_page_info(self): @@ -574,7 +572,7 @@ """ self.page, self.date, self.length, _, user, comment = item self.user = pywikibot.User(self.site, user) - return super(CleaningBot, self).init_page(self.page) + return super().init_page(self.page)
def setup(self): """Setup bot before running.""" diff --git a/scripts/freebasemappingupload.py b/scripts/freebasemappingupload.py index 6e42f0a..848ec4d 100755 --- a/scripts/freebasemappingupload.py +++ b/scripts/freebasemappingupload.py @@ -14,12 +14,10 @@ default: fb2w.nt.gz """ # -# (C) Pywikibot team, 2013-2018 +# (C) Pywikibot team, 2013-2020 # # Distributed under the terms of the MIT license. # -from __future__ import absolute_import, division, unicode_literals - import gzip import os import sys @@ -27,7 +25,7 @@ import pywikibot
-class FreebaseMapperRobot(object): +class FreebaseMapperRobot:
"""Freebase Mapping bot."""
diff --git a/scripts/image.py b/scripts/image.py index 7be7ab9..b2a9f2f 100755 --- a/scripts/image.py +++ b/scripts/image.py @@ -38,14 +38,14 @@
""" # -# (C) Pywikibot team, 2013-2018 +# (C) Pywikibot team, 2013-2020 # # Distributed under the terms of the MIT license. # -from __future__ import absolute_import, division, unicode_literals - import re
+from typing import Optional + import pywikibot
from pywikibot import i18n, pagegenerators @@ -59,17 +59,16 @@
"""This bot will replace or remove all occurrences of an old image."""
- def __init__(self, generator, old_image, new_image=None, **kwargs): + def __init__(self, generator, old_image: str, + new_image: Optional[str] = None, **kwargs): """ Initializer.
@param generator: the pages to work on @type generator: iterable @param old_image: the title of the old image (without namespace) - @type old_image: str @param new_image: the title of the new image (without namespace), or None if you want to remove the image - @type new_image: str or None """ self.available_options.update({ 'summary': None, @@ -120,10 +119,10 @@ else: replacements.append((image_regex, ''))
- super(ImageRobot, self).__init__(self.generator, replacements, - always=self.opt.always, - site=self.site, - summary=summary) + super().__init__(self.generator, replacements, + always=self.opt.always, + site=self.site, + summary=summary)
def main(*args): diff --git a/scripts/imagerecat.py b/scripts/imagerecat.py index 63c9e6e..9b6f357 100755 --- a/scripts/imagerecat.py +++ b/scripts/imagerecat.py @@ -12,12 +12,10 @@ working on an image multiple times. """ # -# (C) Pywikibot team, 2008-2019 +# (C) Pywikibot team, 2008-2020 # # Distributed under the terms of the MIT license. # -from __future__ import absolute_import, division, unicode_literals - import pywikibot
from pywikibot import pagegenerators, textlib diff --git a/scripts/lonelypages.py b/scripts/lonelypages.py index 3b9655f..03a724e 100755 --- a/scripts/lonelypages.py +++ b/scripts/lonelypages.py @@ -22,12 +22,10 @@ python pwb.py lonelypages -enable:User:Bot/CheckBot -always """ # -# (C) Pywikibot team, 2006-2019 +# (C) Pywikibot team, 2006-2020 # # Distributed under the terms of the MIT license. # -from __future__ import absolute_import, division, unicode_literals - import re import sys
@@ -40,7 +38,7 @@ docuReplacements = {'¶ms;': pagegenerators.parameterHelp} # noqa: N816
-class OrphanTemplate(object): +class OrphanTemplate:
"""The orphan template configuration."""
diff --git a/scripts/makecat.py b/scripts/makecat.py index 2acecac..e4f59af 100755 --- a/scripts/makecat.py +++ b/scripts/makecat.py @@ -41,12 +41,10 @@ * [l]ist - show current list of pages to include or to check
""" -# (C) Pywikibot team, 2004-2019 +# (C) Pywikibot team, 2004-2020 # # Distributed under the terms of the MIT license. # -from __future__ import absolute_import, division, unicode_literals - import codecs
import pywikibot @@ -70,7 +68,7 @@ 'keepparent': False, 'nodate': False, }) - super(MakeCatBot, self).__init__(**kwargs) + super().__init__(**kwargs) self.skipdates = self.opt.nodate self.checkforward = True self.checkbackward = not self.opt.forward diff --git a/scripts/selflink.py b/scripts/selflink.py index 2bb28c1..d6b39df 100755 --- a/scripts/selflink.py +++ b/scripts/selflink.py @@ -13,12 +13,10 @@ ¶ms; """ # -# (C) Pywikibot team, 2006-2019 +# (C) Pywikibot team, 2006-2020 # # Distributed under the terms of the MIT license. # -from __future__ import absolute_import, division, unicode_literals - import pywikibot
from pywikibot.bot import Choice, MultipleSitesBot @@ -35,7 +33,7 @@ """A choice to make the title bold."""
def __init__(self, page, replacer): - super(_BoldChoice, self).__init__('make bold', 'b', replacer) + super().__init__('make bold', 'b', replacer) self._page = page
def handle(self): @@ -50,12 +48,12 @@
def __init__(self, generator, **kwargs): """Initializer.""" - super(SelflinkBot, self).__init__(**kwargs) + super().__init__(**kwargs) self.generator = generator
def _create_callback(self): """Create callback and add a choice to make the link bold.""" - callback = super(SelflinkBot, self)._create_callback() + callback = super()._create_callback() callback.additional_choices += [_BoldChoice(self.current_page, callback)] return callback