Miksus / red-bird

Repository Patterns for Python
https://red-bird.readthedocs.io
MIT License
163 stars 22 forks source link

Pydantic v2 Support #49

Open Jypear opened 1 year ago

Jypear commented 1 year ago

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 modelorm 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.

Jypear commented 11 months ago

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.

The rest are just migration pieces. Please feel free to pull me up on anything in a review when you get chance.

gregoryfoster commented 3 weeks ago

@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