How to debug user warning in pydantic

Tags:

When pydantic comes across serialization issues, it outputs:

UserWarning: Pydantic serializer warnings:
  Expected `dict[str, any]` but got `Inputs` - serialized value may not be as expected
  Expected `dict[str, any]` but got `Outputs` - serialized value may not be as expected

But that doesn’t leave much trace to debug. To fix that, change warning filter.

import warnings

warnings.filter("error")

Then now you’ll see stack trace was the warning becomes an exception.

Comments

Leave a Reply

Your email address will not be published. Required fields are marked *