red-bird
red-bird copied to clipboard
Pydantic v2 Support
Creating this as a work in progress/draft PR to get the ball rolling on the pydanticv2 migrations. There's potentially a breaking change (changing the model_orm argument for SQLRepo to just orm). Using "model_" now clashes with a pydantic protected Namespace. We might be able to get round this using a Field alias, but it would require some testing to see if it would still cause the clash.
Tests are still failing at this point but Memory Repo and SQLRepo are running in a basic test.
Will continue to work on this over the weekend hopefully.
Hi @Miksus,
Just to let you know I've now marked this PR ready for review. I've got rid of all failing tests and deprecation warnings (bar one, I have no idea where this is coming from). There will also be some outstanding issues, this project uses pydantic-sqlalchemy, which ties pydantic to version 1. There is a PR which I have dropped a comment on to see if that can get pushed out.
Breaking changes
This PR contains breaking changes for anybody that consumes this, so you may have to version this appropriately.
- 'model_orm' has been changed to 'orm' in the SQLRepo. This is because 'model_' is now a protected namespace inside pydantic.
- This is yet to be tested, but due to the way that pydantic now handles the Optional type and default arguments, I'm not sure if that will have a lasting affect on optional fields inside Repos
The rest are just migration pieces. Please feel free to pull me up on anything in a review when you get chance.
@Jypear, thanks for your work on this, I've switched to your fork for my projects. To avoid the model_orm
breaking change, have you considered removing model_
from the set of Pydantic protected namespaces on the SQLRepo
class?
https://github.com/pydantic/pydantic/discussions/7121#discussioncomment-6849030