-
Notifications
You must be signed in to change notification settings - Fork 163
Description
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
- Install Python 3.14.0
- Install solara and pytest
- Run
pytest --version
or any pytest command - 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.