Skip to main content

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

AttributeTypeDescription
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.
warningsVec< 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

NameTypeDescription
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

NameTypeDescription
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

NameTypeDescription
error[PydanticSerializationUnexpectedValue](../errors/pydanticserializationunexpectedvalue.md?sid=serializers_errors_pydanticserializationunexpectedvalue)The specific error detail representing the unexpected value encountered during the serialization process.

Returns

TypeDescription
null

should_warn()

def should_warn() - > bool

Determines if the collector is currently configured to capture or emit warnings.

Returns

TypeDescription
boolTrue if the current WarningsMode allows for warning collection, otherwise False.