Initial Checks
Description
On python 3.12.0 - 3.12.3, the recently released pydantic-1.10.20 doesn't work with forward ref type annotations.
Downgrading to pydantic-1.10.19 does not throw the exception.
Potentially related to #9609
Example Code
from pydantic import BaseModel
class Schema(BaseModel):
test: "Foo"
Foo = str
"""
Traceback (most recent call last):
File "//ts.py", line 4, in <module>
class Schema(BaseModel):
File "/usr/local/lib/python3.12/site-packages/pydantic/main.py", line 292, in __new__
cls.__try_update_forward_refs__()
File "/usr/local/lib/python3.12/site-packages/pydantic/main.py", line 813, in __try_update_forward_refs__
update_model_forward_refs(cls, cls.__fields__.values(), cls.__config__.json_encoders, localns, (NameError,))
File "/usr/local/lib/python3.12/site-packages/pydantic/typing.py", line 566, in update_model_forward_refs
update_field_forward_refs(f, globalns=globalns, localns=localns)
File "/usr/local/lib/python3.12/site-packages/pydantic/typing.py", line 532, in update_field_forward_refs
field.type_ = evaluate_forwardref(field.type_, globalns, localns or None)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.12/site-packages/pydantic/typing.py", line 75, in evaluate_forwardref
return cast(Any, type_)._evaluate(globalns, localns, type_params=(), recursive_guard=set())
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
TypeError: ForwardRef._evaluate() got an unexpected keyword argument 'type_params'
"""
Python, Pydantic & OS Version
python==3.12.3
pydantic==1.10.20
debian 12 (python:3.12.3 docker image)
Affected Components
Initial Checks
Description
On python 3.12.0 - 3.12.3, the recently released pydantic-1.10.20 doesn't work with forward ref type annotations.
Downgrading to pydantic-1.10.19 does not throw the exception.
Potentially related to #9609
Example Code
Python, Pydantic & OS Version
Affected Components
.model_dump()and.model_dump_json()model_construct(), pickling, private attributes, ORM mode