Open slingshotvfx opened 5 months ago
Should be noted that I fixed this for now by iterating root.items():
def __iter__(self):
return iter(self.root.items())
However, this might not work for everyone's codebase if they expect a RootModel
to behave like a dictionary and it's not what pydantic explicitly suggests in their docs.
Hi @slingshotvfx , Thank you for the catch. Yup, it should expect other types. I'll think how to fix this. Thank you for the catch
Describe the bug Re-implementing
__iter__
methods on RootModels is common and even recommended in the in the Pydantic docs: https://docs.pydantic.dev/latest/concepts/models/#rootmodel-and-custom-root-types)Doing so seems to break model.save() in Beanie with:
TypeError: cannot unpack non-iterable int object
To Reproduce
Traceback:
Additional context python v3.12.1 pydantic 2.5.3 pydantic-core 2.14.6 pydantic-settings 2.1.0 beanie 1.24.0
Thanks for all your work on Beanie!