-
-
Notifications
You must be signed in to change notification settings - Fork 139
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
Support Pydantic 2.0 #279
Comments
We use TypedDict to represent record and field dicts that get returned by Airtable. I don't think it's always practical for us to convert those into models, and it would be a significant change for library users whose code expects those objects as dicts. (Maybe in 3.0) I do think there's a way to make this library work with both v1 and v2 (it involves conditional imports) but I think we can take our time doing it. As you pointed out, Pydantic 2 made a lot of breaking API changes, so I doubt many people are in a hurry to switch. (FWIW I do have a couple branches in the works which use BaseModel for net new data structures, like comments and webhooks. Will post those soon.) |
I see. While the Would you entertain the idea of returning a subclasses of class DictBaseModel(BaseModel):
def __getitem__(self, key):
return getattr(self, key) instead of |
I think we can entertain any idea as long as it demonstrates value. Does this change help us add any new features or capabilities to the library? |
I feel the main advantage is, Pydantic is a lot more popular than
Since PyAirtable already depends on Pydantic internally, it would make sense to also use it for the interface. And now would be a good time for this switch, before the TypedDict implementation hit a release. I think the change would be very straightforward. If you feel like it's worth it, I can implement it. I have not used |
TypedDict is part of the Python standard library; you can read more about it here. I don't think it's confusing for parts of the pyAirtable API, like At this point the primary argument for not changing the return type of For now I think the scope of this issue should be limited to supporting both Pydantic v1 and v2 (so we can minimize dependency conflicts) or, if that proves impossible, migrating to Pydantic v2 once it's clear that the older version of the library is no longer the dominant dependency (but we're not there yet). |
Resolved in #288 🙌 |
Pydantic 2.0 removed
create_model_from_typeddict()
without a warning, which breaks pyairtable.Can't say I agree with them just yanking functions without a deprecation warning, but that's on them.
I never used TypedDict. Is there a reason to use it instead of BaseModel, since we already depend on pydantic? @mesozoic , are you ok if I move the types to BaseModel?
The text was updated successfully, but these errors were encountered: