Skip to content

Commit

Permalink
Specify recursive_guard as kwarg in FutureRef._evaluate
Browse files Browse the repository at this point in the history
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 accomodate 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 <vfazio@gmail.com>
  • Loading branch information
vfazio committed Jun 10, 2024
1 parent 9eaa67b commit 0a1b647
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion pydantic/typing.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,9 @@ def evaluate_forwardref(type_: ForwardRef, globalns: Any, localns: Any) -> Any:
def evaluate_forwardref(type_: ForwardRef, globalns: Any, localns: Any) -> Any:
# Even though it is the right signature for python 3.9, mypy complains with
# `error: Too many arguments for "_evaluate" of "ForwardRef"` hence the cast...
return cast(Any, type_)._evaluate(globalns, localns, set())
# Python 3.13/3.12.4+ made `recursive_guard` a kwarg, so name it explicitly to avoid:
# TypeError: ForwardRef._evaluate() missing 1 required keyword-only argument: 'recursive_guard'
return cast(Any, type_)._evaluate(globalns, localns, recursive_guard=set())


if sys.version_info < (3, 9):
Expand Down

0 comments on commit 0a1b647

Please sign in to comment.