Skip to content

Commit 78c0401

Browse files
committed
Specify recursive_guard as kwarg in FutureRef._evaluate
In CPython 3.12.4/3.13, the function signature of `FutureRef._evaluate` changed such that `recursive_guard` is no longer a positional argument; it is now keyword only [0][1]. To accommodate this, specify `recursive_guard` as a kwarg. This syntax is backwards compatible with earlier versions of the function signature. [0]: python/cpython#118104 [1]: python/cpython#118009 Signed-off-by: Vincent Fazio <[email protected]>
1 parent 9eaa67b commit 78c0401

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

pydantic/typing.py

+3-1
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,9 @@ def evaluate_forwardref(type_: ForwardRef, globalns: Any, localns: Any) -> Any:
6363
def evaluate_forwardref(type_: ForwardRef, globalns: Any, localns: Any) -> Any:
6464
# Even though it is the right signature for python 3.9, mypy complains with
6565
# `error: Too many arguments for "_evaluate" of "ForwardRef"` hence the cast...
66-
return cast(Any, type_)._evaluate(globalns, localns, set())
66+
# Python 3.13/3.12.4+ made `recursive_guard` a kwarg, so name it explicitly to avoid:
67+
# TypeError: ForwardRef._evaluate() missing 1 required keyword-only argument: 'recursive_guard'
68+
return cast(Any, type_)._evaluate(globalns, localns, recursive_guard=set())
6769

6870

6971
if sys.version_info < (3, 9):

0 commit comments

Comments
 (0)