solara icon indicating copy to clipboard operation
solara copied to clipboard

RuntimeError: dictionary changed size during iteration in minisettings.py on Python 3.14

Open EwoutH opened this issue 1 month ago • 2 comments
trafficstars

Solara fails to import on Python 3.14 due to a RuntimeError: dictionary changed size during iteration in minisettings.py. Python 3.14 has stricter enforcement of dictionary iteration rules, causing the error when cls.__dict__ is modified during iteration in __init_subclass__.

Expected Behavior

Solara should import successfully and pytest should be able to discover and load the solara plugin without errors on Python 3.14.

Current Behavior

When running pytest with solara installed on Python 3.14, the import fails with:

RuntimeError: dictionary changed size during iteration

The error occurs in /solara/minisettings.py at line 123 in __init_subclass__:

for key, field in cls.__dict__.items():

This causes pytest to fail during plugin loading when it tries to import solara, preventing any tests from running.

Steps to Reproduce the Problem

  1. Install Python 3.14.0
  2. Install solara and pytest
  3. Run pytest --version or any pytest command
  4. Observe the RuntimeError during import

Full stack trace:

File "/opt/hostedtoolcache/Python/3.14.0/x64/lib/python3.14/site-packages/solara/minisettings.py", line 123, in __init_subclass__
    for key, field in cls.__dict__.items():
                      ~~~~~~~~~~~~~~~~~~^^
RuntimeError: dictionary changed size during iteration

Specifications

  • Solara Version: (latest from PyPI as of the error)
  • Platform: Linux (GitHub Actions hosted runner)
  • Affected Python Versions: Python 3.14.0

Additional Context

Python 3.14 has stricter enforcement around dictionary iteration. When a dictionary is modified during iteration, it now raises a RuntimeError. The fix should be straightforward - iterate over a snapshot of the dictionary instead:

for key, field in list(cls.__dict__.items()):

This issue blocks migration to Python 3.14 for projects using solara.

EwoutH avatar Oct 08 '25 10:10 EwoutH

@maartenbreddels could you or one of your team members pick this up?

EwoutH avatar Oct 16 '25 12:10 EwoutH

@maartenbreddels we're still blocked on this. Is this on your radar?

EwoutH avatar Oct 28 '25 08:10 EwoutH

Sorry I didn't reply earlier, see https://github.com/widgetti/solara/pull/1108#issuecomment-3497710127

maartenbreddels avatar Nov 06 '25 15:11 maartenbreddels