testflows / TestFlows-GitHub-Hetzner-Runners

Autoscaling Self-Hosted GitHub Actions Runners on Hetzner Cloud.
https://testflows.com
Other
34 stars 3 forks source link

mutable default for field deploy is not allowed: use default_factory #11

Closed NiklasRosenstein closed 10 months ago

NiklasRosenstein commented 10 months ago

The config dataclasses in testflows use mutable default values, causing an error like the following in Python 3.11+:

  File "/root/.pex/installed_wheels/601f4b6502885652ae5175b207ca02309d8e405ba63406ece0addf0dcc9f3919/testflows.github.hetzner.runners-1.5.231020.1122452-py3-none-any.whl/.prefix/bin/github-hetzner-runners", line 38, in <module>
    from testflows.github.hetzner.runners.scale_up import scale_up
  File "/root/.pex/installed_wheels/601f4b6502885652ae5175b207ca02309d8e405ba63406ece0addf0dcc9f3919/testflows.github.hetzner.runners-1.5.231020.1122452-py3-none-any.whl/testflows/github/hetzner/runners/scale_up.py", line 27, in <module>
    from .config import Config, check_image
  File "/root/.pex/installed_wheels/601f4b6502885652ae5175b207ca02309d8e405ba63406ece0addf0dcc9f3919/testflows.github.hetzner.runners-1.5.231020.1122452-py3-none-any.whl/testflows/github/hetzner/runners/config/__init__.py", line 15, in <module>
    from .config import Config
  File "/root/.pex/installed_wheels/601f4b6502885652ae5175b207ca02309d8e405ba63406ece0addf0dcc9f3919/testflows.github.hetzner.runners-1.5.231020.1122452-py3-none-any.whl/testflows/github/hetzner/runners/config/config.py", line 81, in <module>
    @dataclass
     ^^^^^^^^^
  File "/usr/local/lib/python3.11/dataclasses.py", line 1230, in dataclass
    return wrap(cls)
           ^^^^^^^^^
  File "/usr/local/lib/python3.11/dataclasses.py", line 1220, 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 'testflows.github.hetzner.runners.config.config.deploy'> for field deploy is not allowed: use default_factory
vzakaznikov commented 10 months ago

Thanks for reporting this issue! I will work on fixing it.

vzakaznikov commented 10 months ago

Should be fixed in https://pypi.org/project/testflows.github.hetzner.runners/1.5.240111.1152038/.