0-8-4 / miui-auto-tasks

一个自动化完成小米社区任务的脚本
MIT License
942 stars 173 forks source link

建议修改一下readme,提示用户使用3.10以上的python版本 #287

Open TJUGERKFER opened 3 months ago

TJUGERKFER commented 3 months ago

Verify Steps

MIUITask Version

v1.7.6-hotfix1

Bug Found in Environment

Linux

Bug Found in Python Version

3.8

Describe the Bug

在windows系统下使用3.11版本的python可以正常运行脚本,但是换用玩客云上的3.8版本python执行脚本报错,提示:

    from utils.api.login import Login
  File "/root/sign/utils/api/login.py", line 17, in <module>
    from .sign import BaseSign
  File "/root/sign/utils/api/sign.py", line 17, in <module>
    from ..utils import get_random_chars_as_string, is_incorrect_return
  File "/root/sign/utils/utils.py", line 95, in <module>
    async def get_token_by_captcha(url: str) -> str | bool:
TypeError: unsupported operand type(s) for |: 'type' and 'type'

经过查找资料得知在python3.10之前,联合类型并不直接被支持作为类型注解。因为玩客云本身的源只有3.8版本的python,所以按照ChatGPT的提示,引入typing.Union之后把类型注解改为Union[str, bool]之后就能正常运行了。希望能更新一下Readme,提示用户更新自己的python版本到3.10或者以上的版本

MIUITask Log

File "/root/sign/miuitask.py", line 15, in <module>
    from utils.api.login import Login
  File "/root/sign/utils/api/login.py", line 17, in <module>
    from .sign import BaseSign
  File "/root/sign/utils/api/sign.py", line 17, in <module>
    from ..utils import get_random_chars_as_string, is_incorrect_return
  File "/root/sign/utils/utils.py", line 95, in <module>
    async def get_token_by_captcha(url: str) -> str | bool:
TypeError: unsupported operand type(s) for |: 'type' and 'type'

MIUITask Config

No response

Screenshots

No response