If you have a recursive model and call update_forward_refs() on it, it throws an exception like:
File ".../test_pydantic.py", line 8, in <module>
Schema.update_forward_refs(recursive_guard=set())
File ".../.venv/lib/python3.9/site-packages/pydantic/main.py", line 677, in update_forward_refs
update_field_forward_refs(f, globalns=globalns, localns=localns)
File ".../.venv/lib/python3.9/site-packages/pydantic/typing.py", line 233, in update_field_forward_refs
field.type_ = evaluate_forwardref(field.type_, globalns, localns or None)
File ".../.venv/lib/python3.9/site-packages/pydantic/typing.py", line 50, in evaluate_forwardref
return type_._evaluate(globalns, localns)
TypeError: _evaluate() missing 1 required positional argument: 'recursive_guard'
Seems to be coming from this line which calls an internal method that now requires a new argument. It seems like (from some very cursory testing) you could just pass recursive_guard=set() on this line if the version is 3.9.x? Not sure if that's the _right_ solution but it did stop my code from crashing.
Output of python -c "import pydantic.utils; print(pydantic.utils.version_info())":
pydantic version: 1.6.1
pydantic compiled: False
install path: .../.venv/lib/python3.9/site-packages/pydantic
python version: 3.9.0 (default, Oct 6 2020, 04:17:54) [Clang 12.0.0 (clang-1200.0.32.2)]
platform: macOS-10.15.7-x86_64-i386-64bit
optional deps. installed: ['typing-extensions']
from pydantic import BaseModel
class Schema(BaseModel):
another: "Schema"
Schema.update_forward_refs()
Looks like this is covered in #1844 so doesn't need to be addressed independently. I'm going to leave the ticket around so others will find it when encountering this issue.
Looks like this is covered in #1844 so doesn't need to be addressed independently. I'm going to leave the ticket around so others will find it when encountering this issue.
Thanks for leaving this up! I just ran into this issue.
Looks like this is covered in #1844 so doesn't need to be addressed independently. I'm going to leave the ticket around so others will find it when encountering this issue.
Thanks for leaving this up! I just ran into this issue.
Me too. Looking forward to the fix!
Most helpful comment
Looks like this is covered in #1844 so doesn't need to be addressed independently. I'm going to leave the ticket around so others will find it when encountering this issue.