Xqt created this task. Xqt added projects: Pywikibot, Pywikibot-Scripts, good first task. Restricted Application added subscribers: pywikibot-bugs-list, Aklapper.
TASK DESCRIPTION Pywikibot 2.7 and Pywikibot 3.4 has been dropped due to T239542 <https://phabricator.wikimedia.org/T239542> and T213287 <https://phabricator.wikimedia.org/T213287>. Rewrite all scripts in scripts folder to support Python 3 code only. Which scripts should be converted? ---------------------------------- All rPWBC <https://phabricator.wikimedia.org/diffusion/PWBC/> scripts inside the scripts folder except scripts inside following subfolders: - archive: archived scripts only which are desupported - i18n: json translation files only - maintenance: already done with https://gerrit.wikimedia.org/r/c/pywikibot/core/+/610076 which can be used as an example - userscripts: empty folder for bot owners scripts How to convert? --------------- - remove all `__future__` imports - remove all `future_builtins` imports - remove all Python 2 related code. Most of them are something like: if PY2: # Python 2 related code else: # Python 3 code (don't forget to remove the line `from pywikibot.tools import PY2` in such case) try: from pathlib import Path # Python 3 code except ImportError: from pathlib2 import Path # Python 2 code - replace class `MyClass(object):` by `class MyClass:`. This looks like old style but is new style class. - replace `super(MyClass, self).my_method()` by `super().my_method()` - use contextlib.suppress context manager to suppress passed exceptions like try: 1/0 except ZeroDivisionError: pass should become: with suppress(ZeroDivisionError): 1/0 - replace `unicode` usage by `str` - replace `tools.UnicodeType` by `str` - replace `tools.StringType` by `(str, bytes)` but check whether it can be just `str` - replace` tools.py2_encode_utf_8(func)` by `func` - remove tools.UnicodeMixin from class inheritance and replace their `__unicode__` method by `__str__` - replace `for item in iterator: yield item` by `yield from iterator` - use iterator unpacking for multiple ignoring values, e.g. `x, _, _, _ = range(4)` should become` x, *_ = range(4)` - add annotation type hints if appropriate Other thinks to know? --------------------- - convert step by step, one single pathset for one script file. Or maybe a few scripts. This makes review easier. - Refer https://www.mediawiki.org/wiki/Manual:Pywikibot/Development for further information - follow guidelines https://www.mediawiki.org/wiki/Manual:Pywikibot/Development/Guidelines - do not hestiate to ask for support - have fun TASK DETAIL https://phabricator.wikimedia.org/T257399 EMAIL PREFERENCES https://phabricator.wikimedia.org/settings/panel/emailpreferences/ To: Xqt Cc: Aklapper, Xqt, pywikibot-bugs-list, JohnsonLee01, SHEKH, Dijkstra, Khutuck, Soda, Chaytanya, Zkhalido, wiki-helenatxu, Viztor, DannyS712, Wenyi, Kieubinhtb, Tks4Fish, Mh-3110, Asad_Ali_Palijo, Lahi, Soteriaspace, JakeTheDeveloper, Tbscho, MayS, Mdupont, JJMC89, Dvorapa, D3r1ck01, Altostratus, Avicennasis, MuhammadShuaib, Tmalhotra, SimmeD, mys_721tx, jayvdb, Masti, Alchimista, Rxy
_______________________________________________ pywikibot-bugs mailing list pywikibot-bugs@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/pywikibot-bugs