CollectWarnings
This class is responsible for collecting and managing warnings during the serialization process. It stores unexpected value errors in a collection and operates according to a specified warning mode.
Attributes
| Attribute | Type | Description |
|---|---|---|
| mode | [WarningsMode](warningsmode.md?sid=serializers_extra_warningsmode) | Determines the strategy for handling serialization warnings, such as whether to ignore them or collect them for reporting. |
| warnings | Vec< PydanticSerializationUnexpectedValue > | A collection of unexpected value errors encountered during the Pydantic serialization process. |
Constructor
Signature
def CollectWarnings(
mode: [WarningsMode](warningsmode.md?sid=serializers_extra_warningsmode)
) - > null
Parameters
| Name | Type | Description |
|---|---|---|
| mode | [WarningsMode](warningsmode.md?sid=serializers_extra_warningsmode) | The mode determining how warnings should be handled during serialization. |
Signature
@staticmethod
def new(
mode: [WarningsMode](warningsmode.md?sid=serializers_extra_warningsmode)
) - > [CollectWarnings](collectwarnings.md?sid=serializers_extra_collectwarnings)
Parameters
| Name | Type | Description |
|---|---|---|
| mode | [WarningsMode](warningsmode.md?sid=serializers_extra_warningsmode) | The configuration mode determining how serialization warnings should be handled or captured. |
Methods
on_unexpected_value()
def on_unexpected_value(
error: [PydanticSerializationUnexpectedValue](../errors/pydanticserializationunexpectedvalue.md?sid=serializers_errors_pydanticserializationunexpectedvalue)
) - > null
Records an unexpected value encountered during serialization for later reporting.
Parameters
| Name | Type | Description |
|---|---|---|
| error | [PydanticSerializationUnexpectedValue](../errors/pydanticserializationunexpectedvalue.md?sid=serializers_errors_pydanticserializationunexpectedvalue) | The specific error detail representing the unexpected value encountered during the serialization process. |
Returns
| Type | Description |
|---|---|
null |
should_warn()
def should_warn() - > bool
Determines if the collector is currently configured to capture or emit warnings.
Returns
| Type | Description |
|---|---|
bool | True if the current WarningsMode allows for warning collection, otherwise False. |