Miksus / red-bird

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

Pydantic v2 support #46

Open abuchnick-aiola opened 1 year ago

abuchnick-aiola commented 1 year ago

Copying here an issue posted originally on Rocketry, just for the integrity and the tracking - since the problem stems from red-bird. https://github.com/Miksus/rocketry/issues/210

Is your feature request related to a problem? Please describe. red-bird is not compatible with Pydantic V2

Describe the solution you'd like Update Red-Bird (if it is still maintained) to use Pydantic V2

Describe alternatives you've considered None

Additional context Pydantic V2 was released on June 30th, and ever since red-bird and Rocketry are not usable. Traceback for example:

Traceback (most recent call last):
  File "/app/main.py", line 5, in <module>
    from rocketry import Rocketry
  File "/usr/local/lib/python3.9/site-packages/rocketry/__init__.py", line 1, in <module>
    from .session import Session
  File "/usr/local/lib/python3.9/site-packages/rocketry/session.py", line 18, in <module>
    from rocketry.log.defaults import create_default_handler
  File "/usr/local/lib/python3.9/site-packages/rocketry/log/defaults.py", line 1, in <module>
    from redbird.logging import RepoHandler
  File "/usr/local/lib/python3.9/site-packages/redbird/__init__.py", line 2, in <module>
    from .base import BaseRepo, BaseResult
  File "/usr/local/lib/python3.9/site-packages/redbird/base.py", line 116, in <module>
    class BaseRepo(ABC, BaseModel):
  File "/usr/local/lib/python3.9/site-packages/redbird/base.py", line 153, in BaseRepo
    ordered: bool = Field(default=False, const=True)
  File "/usr/local/lib/python3.9/site-packages/pydantic/fields.py", line 675, in Field
    raise PydanticUserError('`const` is removed, use `Literal` instead', code='removed-kwargs')
pydantic.errors.PydanticUserError: `const` is removed, use `Literal` instead
ManiMozaffar commented 1 year ago

I wish if the code were written with duck typing, tried to somehow upgrade it to v2, but as you can see 83 tests failed...

Screenshot 2023-07-08 at 10 10 53
ManiMozaffar commented 1 year ago

48 gives you tempo fix, without actually using v2's implementation for backward compatibility

47 would solve problem, but requires many changes.

ItsCalebJones commented 5 months ago

Any progress on this?

betterthanever2 commented 5 months ago

Is there a roadmap for this? Not being able to use redbird/rocketry with the current version of Pydantic (i.e. at all) is a gigantic bummer