Skip to main content

PydanticModelClassVar

This class represents a class variable within a Pydantic model, ensuring that such variables are correctly identified and ignored by subclasses. It provides standardized methods for serializing and deserializing class variable metadata to and from dictionary formats. The implementation is modeled after the attribute handling patterns found in dataclass plugins.

Attributes

AttributeTypeDescription
namestringthe ClassVar name

Constructor

Signature

def PydanticModelClassVar(
name: string
) - > null

Parameters

NameTypeDescription
namestringThe name of the ClassVar

Signature

def PydanticModelClassVar(
name: string
)

Parameters

NameTypeDescription
namestringThe name of the ClassVar attribute to be managed.

Methods


deserialize()

@classmethod
def deserialize(
data: JsonDict
) - > [PydanticModelClassVar](pydanticmodelclassvar.md?sid=pydantic_mypy_pydanticmodelclassvar)

Based on mypy.plugins.dataclasses.DataclassAttribute.deserialize.

Parameters

NameTypeDescription
dataJsonDictA dictionary containing the serialized state, typically including the 'name' key.

Returns

TypeDescription
[PydanticModelClassVar](pydanticmodelclassvar.md?sid=pydantic_mypy_pydanticmodelclassvar)A new instance of PydanticModelClassVar populated with the provided dictionary data.

serialize()

@classmethod
def serialize() - > JsonDict

Based on mypy.plugins.dataclasses.DataclassAttribute.serialize.

Returns

TypeDescription
JsonDictA dictionary representation of the ClassVar instance containing its name.