Skip to content

Issue with ormsgpack.OPT_SERIALIZE_PYDANTIC in pydantic pydantic >= 2.10.0 #311

Closed
@leon11s

Description

@leon11s

Hey!

After an issue in our app, I started some debugging. After some time, I found an issue with running ormsgpack==1.6.0 with pydantic >= 2.10.0.

Example:

from pydantic import BaseModel
import ormsgpack

class UserUsageOverview(BaseModel):
	total_successful_referrals: int
	current_plan_name: str

usage = UserUsageOverview(total_successful_referrals=5, current_plan_name="test")
value_serialized = ormsgpack.packb(usage, option=ormsgpack.OPT_SERIALIZE_PYDANTIC)

The code give the following error:

Traceback (most recent call last):
File "", line 1, in
TypeError: Type is not msgpack serializable: UserUsageOverview

With previous versions of Pydantic, things work just fine. I tried in Python versions 3.11.9 and 3.12.7

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions