Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

autoreload 3 breaks with pydantic models #14841

Open
iloveitaly opened this issue Mar 17, 2025 · 0 comments
Open

autoreload 3 breaks with pydantic models #14841

iloveitaly opened this issue Mar 17, 2025 · 0 comments

Comments

@iloveitaly
Copy link
Contributor

[autoreload of browser.library failed: Traceback (most recent call last):
  File "/Users/mike/.cache/uv/archive-v0/kNbXlZ4I7_k672roqpeO9/lib/python3.13/site-packages/IPython/extensions/autoreload.py", line 278, in check
    superreload(m, reload, self.old_objects, self.shell)
    ~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/mike/.cache/uv/archive-v0/kNbXlZ4I7_k672roqpeO9/lib/python3.13/site-packages/IPython/extensions/autoreload.py", line 508, in superreload
    update_generic(old_obj, new_obj)
    ~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^
  File "/Users/mike/.cache/uv/archive-v0/kNbXlZ4I7_k672roqpeO9/lib/python3.13/site-packages/IPython/extensions/autoreload.py", line 405, in update_generic
    update(a, b)
    ~~~~~~^^^^^^
  File "/Users/mike/.cache/uv/archive-v0/kNbXlZ4I7_k672roqpeO9/lib/python3.13/site-packages/IPython/extensions/autoreload.py", line 343, in update_class
    if (old_obj == new_obj) is True:
        ^^^^^^^^^^^^^^^^^^
  File "<frozen _collections_abc>", line 838, in __eq__
  File "<frozen _collections_abc>", line 898, in __iter__
  File "/Users/mike/.cache/uv/archive-v0/kNbXlZ4I7_k672roqpeO9/lib/python3.13/site-packages/pydantic/_internal/_mock_val_ser.py", line 47, in __iter__
    return self._get_built().__iter__()
           ~~~~~~~~~~~~~~~^^
  File "/Users/mike/.cache/uv/archive-v0/kNbXlZ4I7_k672roqpeO9/lib/python3.13/site-packages/pydantic/_internal/_mock_val_ser.py", line 58, in _get_built
    raise PydanticUserError(self._error_message, code=self._code)
pydantic.errors.PydanticUserError: Pydantic models should inherit from BaseModel, BaseModel cannot be instantiated directly

For further information visit https://errors.pydantic.dev/2.10/u/base-model-instantiated
]

however, autoreload 2 works fine. Ideally, we could catch this specific case so it doesn't break the autoreload functionality and just throws a warning.

I'm happy to help with this problem via a PR, I'm just not sure the best way to handle it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant