Skip to content

ConfigModel

Top-level Pydantic model for the PUM configuration file.

Bases: PumCustomBaseModel

ConfigModel represents the main configuration schema for the application.

Attributes:

Name Type Description
pum PumModel | None

The PUM (Project Update Manager) configuration. Defaults to a new PumModel instance.

parameters list[ParameterDefinitionModel] | None

List of parameter definitions. Defaults to an empty list.

application ApplicationModel | None

Configuration for application hooks. Defaults to a new ApplicationModel instance.

changelogs_directory str | None

Directory path for changelogs. Defaults to "changelogs".

roles list[RoleModel] | None

List of role definitions. Defaults to None.

Source code in pum/config_model.py
class ConfigModel(PumCustomBaseModel):
    """
    ConfigModel represents the main configuration schema for the application.

    Attributes:
        pum: The PUM (Project Update Manager) configuration. Defaults to a new PumModel instance.
        parameters: List of parameter definitions. Defaults to an empty list.
        application: Configuration for application hooks. Defaults to a new ApplicationModel instance.
        changelogs_directory: Directory path for changelogs. Defaults to "changelogs".
        roles: List of role definitions. Defaults to None.
    """

    pum: PumModel | None = Field(default_factory=PumModel)
    parameters: list[ParameterDefinitionModel] | None = []
    application: ApplicationModel | None = Field(
        default_factory=ApplicationModel, alias="migration_hooks"
    )
    changelogs_directory: str | None = "changelogs"
    roles: list[RoleModel] | None = []
    demo_data: list[DemoDataModel] | None = []
    dependencies: list[DependencyModel] | None = []
    uninstall: list[HookModel] | None = []

    @model_validator(mode="before")
    def handle_legacy_field_names(cls, values):
        """Support legacy field names for backward compatibility."""
        # If new name doesn't exist but old name does, use old name
        if "application" not in values and "migration_hooks" in values:
            values["application"] = values.pop("migration_hooks")
        return values

handle_legacy_field_names

handle_legacy_field_names(values)

Support legacy field names for backward compatibility.

Source code in pum/config_model.py
@model_validator(mode="before")
def handle_legacy_field_names(cls, values):
    """Support legacy field names for backward compatibility."""
    # If new name doesn't exist but old name does, use old name
    if "application" not in values and "migration_hooks" in values:
        values["application"] = values.pop("migration_hooks")
    return values