yera.config.loaders.profiles

Yera profile loader — reads and validates profile config from yera.toml.

Symbols

def get_profile — Look up a named Yera profile from the loaded profiles config.
def load_profiles — Read ``[profiles]`` from yera.toml and build a ``Profiles`` instance.
def read_pyproject_yera_profile — Read Yera profile override from ``[tool.yera.profiles]`` in pyproject.toml.
def resolve_active_profile — Determine the effective Yera profile name using the resolution order.

get_profile

get_profile(
    profile_name: str,
    profiles: Profiles,
) → Profile

Look up a named Yera profile from the loaded profiles config.

Parameters

profile_name
type: str

Name of the Yera profile to retrieve.

profiles
type: Profiles

The loaded Yera profiles config.

Returns

type: Profile

The matching Yera profile object.

Raises

ProfileNotFoundInConfigError

If no profile with the given name exists in profiles.

load_profiles

load_profiles() → Profiles | None

Read [profiles] from yera.toml and build a Profiles instance.

Returns an empty Profiles when the section or file is absent. Validation is eager — malformed profile config raises immediately via Pydantic.

Returns

type: Profiles | None

A Profiles instance populated from yera.toml, or None if the section is absent.

Raises

ProfileInvalidConfigError

If the profiles section fails Pydantic validation.

read_pyproject_yera_profile

read_pyproject_yera_profile() → str | None

Read Yera profile override from [tool.yera.profiles] in pyproject.toml.

Looks for a default key under [tool.yera.profiles], e.g. [tool.yera.profiles] default = "work" overrides the active Yera profile for this project.

Returns

type: str | None

The profile name string if present and valid, otherwise None.

resolve_active_profile

resolve_active_profile(
    profile_override: str | None,
    profiles: Profiles,
    pyproject_profile: str | None = None,
) → str

Determine the effective Yera profile name using the resolution order.

Priority: CLI --profile override → pyproject.toml profiles default → yera.toml profiles default → raise.

Parameters

profile_override
type: str | None

Explicit profile name from a CLI --profile flag, or None.

profiles
type: Profiles

The loaded Yera profiles config.

pyproject_profile
type: str | None = None

Active profile override from pyproject.toml, or None. Callers should pass the result of read_pyproject_yera_profile().

Returns

type: str

The resolved active profile name string.

Raises

ProfileNotSpecifiedError

If no profile can be resolved from any source.