Page MenuHomePhabricator

Scripts are failing with Python 3.5.0 after adding type hints
Closed, ResolvedPublic

Description

After adding type hints with rPWBC3a5f5d71 Python 3.5.0 fails (using generate_user_files.py):
https://ci.appveyor.com/project/Ladsgroup/pywikibot-g4xqx/builds/40013767

[00:01:50] python -Werror::UserWarning -m generate_user_files -dir:%PYWIKIBOT_DIR% -family:wikipedia -lang:en -v -debug -user:%PYWIKIBOT_USERNAME%
[00:01:50] Traceback (most recent call last):
[00:01:50]   File "C:\Python350-x64\lib\runpy.py", line 170, in _run_module_as_main
[00:01:50]     "__main__", mod_spec)
[00:01:50]   File "C:\Python350-x64\lib\runpy.py", line 85, in _run_code
[00:01:50]     exec(code, run_globals)
[00:01:50]   File "C:\projects\pywikibot-g4xqx\generate_user_files.py", line 35, in <module>
[00:01:50]     pywikibot = _import_with_no_user_config('pywikibot')
[00:01:50]   File "C:\projects\pywikibot-g4xqx\generate_family_file.py", line 283, in _import_with_no_user_config
[00:01:50]     result = __import__(*import_args)
[00:01:50]   File "C:\projects\pywikibot-g4xqx\pywikibot\__init__.py", line 36, in <module>
[00:01:50]     from pywikibot.bot import (
[00:01:50]   File "C:\projects\pywikibot-g4xqx\pywikibot\bot.py", line 112, in <module>
[00:01:50]     from pywikibot.bot_choice import (
[00:01:50]   File "C:\projects\pywikibot-g4xqx\pywikibot\bot_choice.py", line 265, in <module>
[00:01:50]     class Choice(StandardOption):
[00:01:50]   File "C:\projects\pywikibot-g4xqx\pywikibot\bot_choice.py", line 270, in Choice
[00:01:50]     replacer: Optional['pywikibot.bot.InteractiveReplace']
[00:01:50]   File "C:\Python350-x64\lib\typing.py", line 631, in __getitem__
[00:01:50]     return Union[arg, type(None)]
[00:01:50]   File "C:\Python350-x64\lib\typing.py", line 534, in __getitem__
[00:01:50]     dict(self.__dict__), parameters, _root=True)
[00:01:50]   File "C:\Python350-x64\lib\typing.py", line 491, in __new__
[00:01:50]     for t2 in all_params - {t1} if not isinstance(t2, TypeVar)):
[00:01:50]   File "C:\Python350-x64\lib\typing.py", line 491, in <genexpr>
[00:01:50]     for t2 in all_params - {t1} if not isinstance(t2, TypeVar)):
[00:01:50]   File "C:\Python350-x64\lib\typing.py", line 185, in __subclasscheck__
[00:01:50]     self._eval_type(globalns, localns)
[00:01:50]   File "C:\Python350-x64\lib\typing.py", line 172, in _eval_type
[00:01:50]     eval(self.__forward_code__, globalns, localns),
[00:01:50]   File "<string>", line 1, in <module>
[00:01:50] AttributeError: module 'pywikibot' has no attribute 'bot'

Event Timeline

Xqt triaged this task as High priority.Jul 17 2021, 9:38 AM

Other scripts fails too:

C:\pwb\GIT\core>py -3.5 pwb.py
Traceback (most recent call last):
  File "pwb.py", line 247, in <module>
    import pywikibot as pwb
  File "C:\pwb\GIT\core\pywikibot\__init__.py", line 36, in <module>
    from pywikibot.bot import (
  File "C:\pwb\GIT\core\pywikibot\bot.py", line 112, in <module>
    from pywikibot.bot_choice import (
  File "C:\pwb\GIT\core\pywikibot\bot_choice.py", line 280, in <module>
    class Choice(StandardOption):
  File "C:\pwb\GIT\core\pywikibot\bot_choice.py", line 285, in Choice
    replacer: Optional['pywikibot.bot.InteractiveReplace']
  File "C:\Python35\lib\typing.py", line 631, in __getitem__
    return Union[arg, type(None)]
  File "C:\Python35\lib\typing.py", line 534, in __getitem__
    dict(self.__dict__), parameters, _root=True)
  File "C:\Python35\lib\typing.py", line 491, in __new__
    for t2 in all_params - {t1} if not isinstance(t2, TypeVar)):
  File "C:\Python35\lib\typing.py", line 491, in <genexpr>
    for t2 in all_params - {t1} if not isinstance(t2, TypeVar)):
  File "C:\Python35\lib\typing.py", line 185, in __subclasscheck__
    self._eval_type(globalns, localns)
  File "C:\Python35\lib\typing.py", line 172, in _eval_type
    eval(self.__forward_code__, globalns, localns),
  File "<string>", line 1, in <module>
AttributeError: module 'pywikibot' has no attribute 'bot'
Exiting due to uncaught exception <class 'AttributeError'>
Xqt renamed this task from generate_user_files.py fails with Python 3.5.0 to Scripts are failing with Python 3.5.0 after adding type hints.Jul 20 2021, 2:01 PM

Change 705790 had a related patch set uploaded (by Xqt; author: Xqt):

[pywikibot/core@master] [bugfix] remove typing hints with pywikibot.bot access

https://gerrit.wikimedia.org/r/705790

Xqt claimed this task.
Xqt added a project: Regression.

Change 705790 merged by jenkins-bot:

[pywikibot/core@master] [bugfix] remove typing hints with pywikibot.bot access

https://gerrit.wikimedia.org/r/705790

Change 708354 had a related patch set uploaded (by Damian; author: Damian):

[pywikibot/core@master] [IMPR] Restore bot_choice type hints

https://gerrit.wikimedia.org/r/708354

Change 708354 abandoned by Damian:

[pywikibot/core@master] [IMPR] Restore bot_choice type hints

Reason:

Xqt would prefer to await removal of Python 3.5.0 support.

https://gerrit.wikimedia.org/r/708354