awslabs/aws-build-accumulator

Litani init fails with Python 3.11

iMichka opened this issue · 1 comments

Hi. Homebrew maintainer here. We noticed that Litani is failing to init when used with Python 3.11.
Here is the stacktrace:

=> /home/linuxbrew/.linuxbrew/Cellar/litani/1.27.0/bin/litani init --project-name test-installation
  Traceback (most recent call last):
    File "/home/linuxbrew/.linuxbrew/Cellar/litani/1.27.0/libexec/litani", line 116, in <module>
      asyncio.run(main())
    File "/home/linuxbrew/.linuxbrew/opt/python@3.11/lib/python3.11/asyncio/runners.py", line 190, in run
      return runner.run(main)
             ^^^^^^^^^^^^^^^^
    File "/home/linuxbrew/.linuxbrew/opt/python@3.11/lib/python3.11/asyncio/runners.py", line 118, in run
      return self._loop.run_until_complete(task)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    File "/home/linuxbrew/.linuxbrew/opt/python@3.11/lib/python3.11/asyncio/base_events.py", line 653, in run_until_complete
      return future.result()
             ^^^^^^^^^^^^^^^
    File "/home/linuxbrew/.linuxbrew/Cellar/litani/1.27.0/libexec/litani", line 97, in main
      args = get_args()
             ^^^^^^^^^^
    File "/home/linuxbrew/.linuxbrew/Cellar/litani/1.27.0/libexec/litani", line 65, in get_args
      add_subparsers(subs)
    File "/home/linuxbrew/.linuxbrew/Cellar/litani/1.27.0/libexec/litani", line 35, in add_subparsers
      imported_module = importlib.import_module(module.name)
                        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    File "/home/linuxbrew/.linuxbrew/opt/python@3.11/lib/python3.11/importlib/__init__.py", line 126, in import_module
      return _bootstrap._gcd_import(name[level:], package, level)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    File "<frozen importlib._bootstrap>", line 1206, in _gcd_import
    File "<frozen importlib._bootstrap>", line 1178, in _find_and_load
    File "<frozen importlib._bootstrap>", line 1149, in _find_and_load_unlocked
    File "<frozen importlib._bootstrap>", line 690, in _load_unlocked
    File "<frozen importlib._bootstrap_external>", line 940, in exec_module
    File "<frozen importlib._bootstrap>", line 2[41](https://github.com/Homebrew/homebrew-core/actions/runs/3780379500/jobs/6426469059#step:7:42), in _call_with_frames_removed
    File "/home/linuxbrew/.linuxbrew/Cellar/litani/1.27.0/libexec/lib/ninja.py", line 132, in <module>
      @dataclasses.dataclass
       ^^^^^^^^^^^^^^^^^^^^^
    File "/home/linuxbrew/.linuxbrew/opt/python@3.11/lib/python3.11/dataclasses.py", line 1220, in dataclass
      return wrap(cls)
             ^^^^^^^^^
    File "/home/linuxbrew/.linuxbrew/opt/python@3.11/lib/python3.11/dataclasses.py", line 1210, in wrap
      return _process_class(cls, init, repr, eq, order, unsafe_hash,
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    File "/home/linuxbrew/.linuxbrew/opt/python@3.11/lib/python3.11/dataclasses.py", line 9[58](https://github.com/Homebrew/homebrew-core/actions/runs/3780379500/jobs/6426469059#step:7:59), in _process_class
      cls_fields.append(_get_field(cls, name, type, kw_only))
                        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    File "/home/linuxbrew/.linuxbrew/opt/python@3.11/lib/python3.11/dataclasses.py", line [81](https://github.com/Homebrew/homebrew-core/actions/runs/3780379500/jobs/6426469059#step:7:82)5, in _get_field
      raise ValueError(f'mutable default {type(f.default)} for field '
  ValueError: mutable default <class 'lib.ninja._StatusParser'> for field status_parser is not allowed: use default_factory

For reference Homebrew/homebrew-core#119040

@iMichka this issue can be closed :)