python-wechaty
python-wechaty copied to clipboard
[Bug]: examples/ding-dong-bot.py启动报错
Environment
- wechaty:
- wechaty-puppet:
- wechaty-puppet-service:
- wechaty-plugin-contrib:
- token type: padlocal|wxwork|xp
- the version of wechaty docker container: [0.65]
Description
root@6df367af0032:/wecharty/app/python-wechaty-getting-started# make bot
python3 examples/ding-dong-bot.py
Traceback (most recent call last):
File "/wecharty/app/python-wechaty-getting-started/examples/ding-dong-bot.py", line 21, in <module>
from wechaty import (
File "/usr/local/lib/python3.11/site-packages/wechaty/__init__.py", line 54, in <module>
from .wechaty import (
File "/usr/local/lib/python3.11/site-packages/wechaty/wechaty.py", line 111, in <module>
@dataclass
^^^^^^^^^
File "/usr/local/lib/python3.11/dataclasses.py", line 1220, in dataclass
return wrap(cls)
^^^^^^^^^
File "/usr/local/lib/python3.11/dataclasses.py", line 1210, in wrap
return _process_class(cls, init, repr, eq, order, unsafe_hash,
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.11/dataclasses.py", line 958, in _process_class
cls_fields.append(_get_field(cls, name, type, kw_only))
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.11/dataclasses.py", line 815, in _get_field
raise ValueError(f'mutable default {type(f.default)} for field '
ValueError: mutable default <class 'wechaty_puppet.schemas.puppet.PuppetOptions'> for field puppet_options is not allowed: use default_factory
make: *** [Makefile:79: bot] Error 1
Minimum reproducible code
ValueError: mutable default <class 'wechaty_puppet.schemas.puppet.PuppetOptions'> for field puppet_options is not allowed: use default_factory
<=python3.10
python3.11 dataclasses library is NOT backward compatible
https://github.com/python/cpython/commit/e029c53e1a408b89a4e3edf30a9b38b094f9c880
Hello! I have downgraded python from 3.11 version to 3.9 version and this issue still occurs. Do you have any ideas what could be wrong? I also tested on version 3.10 and there is the same error.