h2020charisma/ramanchada2

missing return in the serialize method

Closed this issue · 3 comments

Missing return in the serialize method

Have you tested that self.model_dump_json() would work?
self is not a Pydantic BaseModel, it is RootModel which does not have a method .model_dump_json() - in spectrastream .json() and/or model_dump(mode='json') worked well... but not model_dump_json().
https://docs.pydantic.dev/latest/api/root_model/#pydantic.root_model.RootModel.model_dump

It works on my machine :)

Here is a little bit of duck typing:

from pydantic import BaseModel, RootModel

class BM(BaseModel):
    a: int
    b: float
    c: str
    
class RM(RootModel):
    root: BM

rm = RM(a='4', b='4', c='4')
rm.model_dump(), rm.model_dump_json()

Moreover:

assert isinstance(rm, BaseModel)

Could you provide a minimal example that illustrates the problem?