Miksus / red-bird

Repository Patterns for Python

Home Page:https://red-bird.readthedocs.io

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Pydantic v2 support

abuchnick-aiola opened this issue · comments

Copying here an issue posted originally on Rocketry, just for the integrity and the tracking - since the problem stems from red-bird.
Miksus/rocketry#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

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

#48 gives you tempo fix, without actually using v2's implementation for backward compatibility
#47 would solve problem, but requires many changes.

Any progress on this?

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