Skip to main content

DataclassArgsSchema

This class defines a schema for dataclass arguments within a type-safe dictionary structure. It specifies required properties such as the dataclass name and its associated fields, while providing optional configurations for computed fields, serialization behavior, and metadata. This schema is primarily used to represent the structural and behavioral requirements for validating and serializing dataclass-based data structures.

Attributes

AttributeTypeDescription
type'dataclass-args'Fixed identifier string used to distinguish this schema as a dataclass arguments validator.
dataclass_namestringThe human-readable name of the dataclass used for error messages and representation.
fieldslist[[DataclassField](dataclassfield.md?sid=pydantic_core_core_schema_dataclassfield)]A list of field definitions that determine how input data is validated and mapped to dataclass attributes.
computed_fieldslist[[ComputedField](../../../../serializers/computed/fields/computedfield.md?sid=serializers_computed_fields_computedfield)]A list of properties or methods decorated as computed fields to be included in the schema output.
collect_init_onlyboolean = FalseWhether to capture and store arguments that are passed to the constructor but not defined as fields.
refstringA unique string identifier used for recursive schema references and shared definitions.
metadatadict[str, Any]A dictionary of custom configuration data used to extend schema behavior or store plugin-specific information.
serializationSerSchemaCustom serialization configuration that defines how the dataclass arguments are converted back to raw data.
extra_behavior[ExtraBehavior](../../../../build/tools/extrabehavior.md?sid=build_tools_extrabehavior)Configuration setting that determines how the validator handles unexpected fields not defined in the schema.

Constructor

Signature

def DataclassArgsSchema() - > null

Methods


type()

def type() - > Literal['dataclass-args']

Identifies the schema type as a dataclass argument structure.

Returns

TypeDescription
Literal['dataclass-args']The fixed literal string 'dataclass-args' used for schema identification

dataclass_name()

def dataclass_name() - > str

Specifies the human-readable name of the dataclass for error reporting and documentation.

Returns

TypeDescription
strThe name of the dataclass

fields()

def fields() - > list[[DataclassField](dataclassfield.md?sid=pydantic_core_core_schema_dataclassfield)]

Defines the list of fields that correspond to the dataclass's init parameters.

Returns

TypeDescription
list[[DataclassField](dataclassfield.md?sid=pydantic_core_core_schema_dataclassfield)]A list of field definitions used for validation and instantiation

computed_fields()

def computed_fields() - > list[[ComputedField](../../../../serializers/computed/fields/computedfield.md?sid=serializers_computed_fields_computedfield)]

Lists fields that are calculated from other attributes rather than being supplied during initialization.

Returns

TypeDescription
list[[ComputedField](../../../../serializers/computed/fields/computedfield.md?sid=serializers_computed_fields_computedfield)]A list of computed field definitions

collect_init_only()

def collect_init_only() - > bool

Determines whether to include fields that are only present in the constructor and not stored as attributes.

Returns

TypeDescription
boolTrue if init-only variables should be collected, False otherwise

ref()

def ref() - > str

Provides a unique identifier for the schema to allow for recursive definitions or shared references.

Returns

TypeDescription
strThe reference string used for internal schema linking

metadata()

def metadata() - > dict[str, Any]

Stores an extensible dictionary of custom data associated with the dataclass schema.

Returns

TypeDescription
dict[str, Any]A dictionary containing arbitrary metadata

serialization()

def serialization() - > SerSchema

Configures how the dataclass should be transformed into a serialized format.

Returns

TypeDescription
SerSchemaThe serialization configuration schema

extra_behavior()

def extra_behavior() - > [ExtraBehavior](../../../../build/tools/extrabehavior.md?sid=build_tools_extrabehavior)

Defines how the validator should handle extra fields that are not explicitly defined in the schema.

Returns

TypeDescription
[ExtraBehavior](../../../../build/tools/extrabehavior.md?sid=build_tools_extrabehavior)The behavior setting for handling unexpected input fields