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
| Attribute | Type | Description |
|---|---|---|
| name | string | the ClassVar name |
Constructor
Signature
def PydanticModelClassVar(
name: string
) - > null
Parameters
| Name | Type | Description |
|---|---|---|
| name | string | The name of the ClassVar |
Signature
def PydanticModelClassVar(
name: string
)
Parameters
| Name | Type | Description |
|---|---|---|
| name | string | The 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
| Name | Type | Description |
|---|---|---|
| data | JsonDict | A dictionary containing the serialized state, typically including the 'name' key. |
Returns
| Type | Description |
|---|---|
[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
| Type | Description |
|---|---|
JsonDict | A dictionary representation of the ClassVar instance containing its name. |