Module pydantic_partials.partial

Global variables

var Partial : TypeAlias

Can be used to manually mark a variable as Partial, which means it can have a Missing assigned to it.

Classes

class AutoPartialModel (*args, **kwargs)
Expand source code
class AutoPartialModel(PartialModel, auto_partials=True):
    pass

Class Args:

  • auto_partials: For more details see PartialConfigDict.auto_partials.
    • If Default: Inherit behavior from parent/model_config; otherwise defaults to True.
    • If True (default): Will automatically make all fields on the model Partial.
    • If False: User needs to mark individual fields as Partial where they want.

Pydantic partial model class, with ability to easily dynamically omit fields when serializing a model.

Ancestors

Class variables

var config_dict : ClassVar[PartialConfigDict]
var model_config
var model_partial_fields
class PartialModel (*args, **kwargs)
Expand source code
class PartialModel(
    BaseModel,

    # Need metaclass to examine fields for missing type
    # and also to auto-add missing type if desired.
    metaclass=PartialMeta,
):
    """
    Class Args:

    - auto_partials: For more details see `pydantic_partials.config.PartialConfigDict.auto_partials`.
        - If `Default`: Inherit behavior from parent/model_config; otherwise defaults to `True`.
        - If `True` (default): Will automatically make all fields on the model `Partial`.
        - If `False`: User needs to mark individual fields as `Partial` where they want.
    """

    config_dict: typing.ClassVar[PartialConfigDict]

    def __init__(self, *args, **kwargs):
        """ Pydantic partial model class, with ability to easily dynamically omit fields when serializing a model.
        """
        super().__init__(*args, **kwargs)

Class Args:

  • auto_partials: For more details see PartialConfigDict.auto_partials.
    • If Default: Inherit behavior from parent/model_config; otherwise defaults to True.
    • If True (default): Will automatically make all fields on the model Partial.
    • If False: User needs to mark individual fields as Partial where they want.

Pydantic partial model class, with ability to easily dynamically omit fields when serializing a model.

Ancestors

  • pydantic.main.BaseModel

Subclasses

Class variables

var config_dict : ClassVar[PartialConfigDict]
var model_config
var model_partial_fields