`autoreload 3` breaks with pydantic models
- 主要語言
- Python
- 星號
- 16.8k
- 分支
- 4.5k
- 平均合併
- 1 天 2 小時
- 30 天內合併 PR
- 6
描述
```
[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 "", line 838, in __eq__
File "", 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.
貢獻指南
評估
這個 Issue 還沒有評估資料。