Skip to content

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

@EwoutH

Description

@EwoutH

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions