-
-
Notifications
You must be signed in to change notification settings - Fork 2.1k
Specify recursive_guard as kwarg in FutureRef._evaluate #9612
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Specify recursive_guard as kwarg in FutureRef._evaluate #9612
Conversation
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 <vfazio@gmail.com>
Note that there are future problems for pydantic in CPython 3.13, but I will open a new issue for that. |
Great, thanks! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Awesome job, thank you!
@sydney-runkle is a new release already scheduled to include this? |
We're planning on a V1 and V2 release at the end of June, but maybe this is pressing enough that we should do a patch. I'll chat with the team this morning and see what they think. |
Thank you @sydney-runkle . Yes, unless there is a workaround / sanctioned "monkey patch", I believe this to be somehow pressing. |
To be transparent, I didn't have time to actually test this under 3.12.4. I don't see the 1.10.x CI matrix running on Python 3.12 at all If we wanted warm and fuzzies, maybe there should be a quick CI update to widen the CI matrix and also add the 3.12 classifier in setup.py? What's the EOL for pydantic v1? Should there be a cap on the required python to be <3.13 ? |
While it was irresponsible of me, the fix does work: Failure to import fastapi on 3.12.4 w/ pydantic 1.10.15
Fixed on new hash
|
@sydney-runkle there are places in the documentation that call out 3.11 specifically (see https://docs.pydantic.dev/latest/contributing/#prerequisites) and that's for current documentation. Before I make this PR, is 3.12 support something pydantic actually wants to advertise support for on 1.10.x? |
Slight modification here - we'll likely still do fixes like this one to support the still-large number of V1 users 🚀. If all tests pass when we add the 3.12 matrices, then I think we can advertise it :). |
I'm going to open an issue to continue the discussion. I don't think it's quite as straightforward as I was hoping. |
For anybody facing this issue when using langchain, the right module to monkey patch is |
|
For pydantic issue pydantic/pydantic#9612
3.12.4 is not suitable - pydantic/pydantic#9612
* Add support of python 3.12 * Replaced openapi-schema-pydantic with openapi-pydantic * 3.12.4 is not suitable - pydantic/pydantic#9612 --------- Co-authored-by: Sergey Bondarenko <>
This should fix errors in combination with Python 3.12, e.g. in build <https://github.com/AKVorrat/dearmep/actions/runs/11783011436/job/32819299151>, which had: TypeError: ForwardRef._evaluate() missing 1 required keyword-only argument: 'recursive_guard' See <pydantic/pydantic#9612>. This is a minimal change to limit the scope, instead of risking breaking changes.
This should fix errors in combination with Python 3.12, e.g. in build <https://github.com/AKVorrat/dearmep/actions/runs/11783011436/job/32819299151>, which had: TypeError: ForwardRef._evaluate() missing 1 required keyword-only argument: 'recursive_guard' See <pydantic/pydantic#9612>. This is a minimal change to limit the scope, instead of risking breaking changes. (cherry picked from commit d46e269)
This should fix errors in combination with Python 3.12, e.g. in build <https://github.com/AKVorrat/dearmep/actions/runs/11783011436/job/32819299151>, which had: TypeError: ForwardRef._evaluate() missing 1 required keyword-only argument: 'recursive_guard' See <pydantic/pydantic#9612>. This is a minimal change to limit the scope, instead of risking breaking changes.
In CPython 3.12.4/3.13, the function signature of
FutureRef._evaluate
changed such thatrecursive_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.Change Summary
Related issue number
Fix #9607 #9609
Checklist
skip change file check