-
Notifications
You must be signed in to change notification settings - Fork 12
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
Pydantic 2 support #34
Conversation
79477de
to
014c0ca
Compare
014c0ca
to
2cfdf49
Compare
fb2b928
to
861b5b4
Compare
- Fixes all e2e tests
861b5b4
to
9db8faa
Compare
e30649d
to
e1af3df
Compare
52cad67
to
a3f25a8
Compare
7b624e4
to
8f4dcc0
Compare
Thank you for your work on this. Do you have an ETA for when this will be merged? |
Hi @PSU3D0, thanks for your interest. I have published them on PyPI, will be glad if you can take a look at them. |
Don't you use drf-spectacular for this? |
@utapyngo honestly saying, I haven't checked the compatibility with Here I meant native |
f140bd7
to
90b46b8
Compare
90b46b8
to
b4ff98a
Compare
e3e22e3
to
1dbbb08
Compare
f396843
to
56ea6e5
Compare
4d5615d
to
9fab2ef
Compare
8fb9b3e
to
f497411
Compare
f497411
to
d76d23c
Compare
Incredible! nice work and thank you. |
I mentioned in #16 that this update should be prepared as soon as Pydantic v2 would go to RC, but well... I'm way behind the release schedule.
This would be a massive update for the library -- all fields will be redesigned from scratch, with as few breaking changes as possible, though Pydantic's interfaces have changed dramatically, so some incompatibilities are inevitable.
V1 fate
I'm planning to maintain compatibility with v1, and the package will include subpackages for both pydantic v1 and v2, and a small compatibility layer to dynamically resolve the correct subpackage based on the installed pydantic version.
There are no further improvements planned for v1. For future releases, it's better to focus on v2, as it has more benefits to support, like better performance and a nicer and cleaner API. Though v1 is still supported, just in maintenance-only state -- any issues coming from it should be taken into consideration.
IMPORTANT: I'm planning to deprecate and remove v1 in 1.0, as it deserves its own major release -- at least it should outlive Pydantic V1 end-of-life date.
Postponed annotations
One of the major areas of improvement is the annotation resolution. Pydantic v2 already has a deferred resolution semantics, unlike v1 which had the
.update_forward_refs()
model method.Previously, the
SchemaField
first tried to resolve forward refs during Django model class initialisation, with a fallback to the first field access if it didn't succeed.With v2, the underlying pydantic adapter becomes lazy and always reveals its type on first access, and now all possible misconfiguration errors are evaluated during Django's
check
command/runserver step.Roadmap
SchemaField
implementationSchemaParser
implementationSchemaRenderer
implementationcoreapi.AutoSchema
implementationopenapi.AutoSchema
implementation