Skip to content

Index

🤖 AI-Generated Content

This documentation was generated with AI assistance and is still being audited. Some, or potentially a lot, of this information may be inaccurate. Learn more.

flavor.config

FlavorPack configuration system built on the Provide Foundation config stack.

Provides typed, validated configuration models that replace ad-hoc env handling.

Classes

BuildConfig

Build-related configuration from the manifest.

ExecutionConfig

Execution-related configuration from the manifest.

FlavorConfig

Bases: BaseConfig

Top-level structured configuration for the [tool.flavor] section.

Functions
from_pyproject_dict classmethod
from_pyproject_dict(
    config: dict[str, Any], project_defaults: dict[str, Any]
) -> FlavorConfig

Factory method to create a validated FlavorConfig from a dictionary.

Parameters:

Name Type Description Default
config dict[str, Any]

The dictionary from the [tool.flavor] section of pyproject.toml.

required
project_defaults dict[str, Any]

A dictionary with fallback values from the [project] section.

required

Returns:

Type Description
FlavorConfig

A validated, immutable FlavorConfig instance.

Raises:

Type Description
ValidationError

If the configuration is invalid.

Source code in flavor/config/config.py
@classmethod
def from_pyproject_dict(cls, config: dict[str, Any], project_defaults: dict[str, Any]) -> FlavorConfig:
    """
    Factory method to create a validated FlavorConfig from a dictionary.

    Args:
        config: The dictionary from the `[tool.flavor]` section of pyproject.toml.
        project_defaults: A dictionary with fallback values from the `[project]` section.

    Returns:
        A validated, immutable FlavorConfig instance.

    Raises:
        ValidationError: If the configuration is invalid.
    """
    name = config.get("name") or project_defaults.get("name")
    if not name:
        raise ValidationError("Project name must be defined in [project].name or [tool.flavor].name")

    version = config.get("version") or project_defaults.get("version")
    if not version:
        raise ValidationError(
            "Project version must be defined in [project].version or [tool.flavor].version"
        )

    entry_point = config.get("entry_point") or project_defaults.get("entry_point")
    if not entry_point:
        raise ValidationError(
            "Project entry_point must be defined in [project].scripts or [tool.flavor].entry_point"
        )

    # Metadata
    meta_conf = config.get("metadata", {})
    metadata = MetadataConfig(package_name=meta_conf.get("package_name"))

    # Build
    build_conf = config.get("build", {})
    build = BuildConfig(dependencies=build_conf.get("dependencies", []))

    # Execution
    exec_conf = config.get("execution", {})
    runtime_conf = exec_conf.get("runtime", {}).get("env", {})
    runtime_env = RuntimeRuntimeConfig(
        unset=runtime_conf.get("unset", []),
        passthrough=runtime_conf.get("pass", []),  # 'pass' is the key in TOML
        set_vars=runtime_conf.get("set", {}),
        map_vars=runtime_conf.get("map", {}),
    )
    execution = ExecutionConfig(runtime_env=runtime_env)

    # System configuration (loaded from environment variables)
    system = SystemConfig()

    return cls(
        name=name,
        version=version,
        entry_point=entry_point,
        metadata=metadata,
        build=build,
        execution=execution,
        system=system,
    )

FlavorRuntimeConfig

Bases: RuntimeConfig

FlavorPack runtime configuration for CLI startup.

MetadataConfig

Bases: RuntimeConfig

Metadata-related configuration from the manifest.

PathsConfig

Bases: RuntimeConfig

Path and directory configuration.

Attributes
effective_cache_home property
effective_cache_home: Path

Get effective cache home directory with fallback.

effective_workenv_base property
effective_workenv_base: Path

Get effective work environment base with fallback.

RuntimeRuntimeConfig

Configuration for the sandboxed runtime environment variables.

SecurityConfig

Bases: RuntimeConfig

Security and validation configuration.

Functions
__attrs_post_init__
__attrs_post_init__() -> None

Validate the security configuration after initialization.

Source code in flavor/config/config.py
def __attrs_post_init__(self) -> None:
    """Validate the security configuration after initialization."""
    if self.validation_level not in VALIDATION_LEVELS:
        valid_levels = ", ".join(VALIDATION_LEVELS.keys())
        raise ValidationError(
            f"Invalid validation level '{self.validation_level}'. Must be one of: {valid_levels}"
        )

SystemConfig

System and environment configuration.

UVConfig

Bases: RuntimeConfig

UV (Python package manager) configuration.

Functions

get_flavor_config

get_flavor_config() -> FlavorConfig

Get the global FlavorConfig instance.

Returns:

Name Type Description
FlavorConfig FlavorConfig

The global configuration instance

Source code in flavor/config/manager.py
def get_flavor_config() -> FlavorConfig:
    """Get the global FlavorConfig instance.

    Returns:
        FlavorConfig: The global configuration instance
    """
    return _config_manager.get_config()

reset_flavor_config

reset_flavor_config() -> None

Reset the global configuration to force reload from environment.

Source code in flavor/config/manager.py
def reset_flavor_config() -> None:
    """Reset the global configuration to force reload from environment."""
    _config_manager.reset_config()

set_flavor_config

set_flavor_config(config: FlavorConfig | None) -> None

Set the global FlavorConfig instance.

Parameters:

Name Type Description Default
config FlavorConfig | None

The FlavorConfig instance to use globally, or None to reset

required
Source code in flavor/config/manager.py
def set_flavor_config(config: FlavorConfig | None) -> None:
    """Set the global FlavorConfig instance.

    Args:
        config: The FlavorConfig instance to use globally, or None to reset
    """
    _config_manager.set_config(config)