You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
RootModel import on Python 3.10.0 (and only 3.10.0) fails with:
...
File "<snipped>/lib/python3.10/site-packages/pydantic/root_model.py", line 26, in <module>
class RootModel(BaseModel, typing.Generic[RootModelRootType]):
File "<snipped>/lib/python3.10/site-packages/pydantic/_internal/_model_construction.py", line 172, in __new__
set_model_fields(cls, bases, config_wrapper, types_namespace)
File "<snipped>/lib/python3.10/site-packages/pydantic/_internal/_model_construction.py", line 400, in set_model_fields
fields, class_vars = collect_model_fields(cls, bases, config_wrapper, types_namespace, typevars_map=typevars_map)
File "<snipped>/lib/python3.10/site-packages/pydantic/_internal/_fields.py", line 98, in collect_model_fields
type_hints = get_cls_type_hints_lenient(cls, types_namespace)
File "<snipped>/lib/python3.10/site-packages/pydantic/_internal/_typing_extra.py", line 212, in get_cls_type_hints_lenient
hints[name] = eval_type_lenient(value, globalns, localns)
File "<snipped>/lib/python3.10/site-packages/pydantic/_internal/_typing_extra.py", line 221, in eval_type_lenient
value = _make_forward_ref(value, is_argument=False, is_class=True)
TypeError: ForwardRef.__init__() got an unexpected keyword argument 'is_class'
The problem does not exist on 3.10.1+.
Seems like the reason is already described here, but for Python 3.9.
Initial Checks
Description
The problem
RootModel
import on Python 3.10.0 (and only 3.10.0) fails with:The problem does not exist on 3.10.1+.
Seems like the reason is already described here, but for Python 3.9.
The fix
Since Pydantic depends on bpo-45166 fix to
get_type_hints
, and that fix was only included in 3.10.1 (was not present in 3.10.0), the hard-coded python version for 3.9 branch here:pydantic/pydantic/_internal/_typing_extra.py
Line 256 in b33a795
should be expanded to include the bpo-45166 fix in the 3.10 branch as well.
Example Code
Python, Pydantic & OS Version
Selected Assignee: @Kludex
The text was updated successfully, but these errors were encountered: