mafw.devtools.dependencies.freeze

Dependency freezing and unfreezing utilities for MAFw.

This module provides functions for adding and removing computed upper-bound constraints in pyproject.toml dependency declarations. It is used by the release workflow to pin dependencies during release and unpin them afterwards.

Functions

format_requirement(requirement)

Serialize a packaging requirement object back to a PEP 508 compatible string.

has_frozen_upper_bound(requirement)

Determine whether a requirement already contains an upper bound constraint.

highest_lower_bound(requirement)

Extract the highest lower-bound version from >= and > specifiers.

iter_specifiers(requirement)

Return a concrete list of specifiers for the given requirement.

summarize_freeze_changes(before, after)

Build a short summary for dry-run output.

update_dependency_list(dependencies, *, ...)

Update a TOML list of dependency strings in-place.

mafw.devtools.dependencies.freeze.format_requirement(requirement: Requirement) str[source]

Serialize a packaging requirement object back to a PEP 508 compatible string.

Parameters:

requirement (Requirement) – Parsed requirement instance.

Returns:

PEP 508 requirement string.

Return type:

str

mafw.devtools.dependencies.freeze.has_frozen_upper_bound(requirement: Requirement) bool[source]

Determine whether a requirement already contains an upper bound constraint.

Parameters:

requirement (Requirement) – Parsed requirement instance.

Returns:

True if the requirement is already frozen.

Return type:

bool

mafw.devtools.dependencies.freeze.highest_lower_bound(requirement: Requirement) str | None[source]

Extract the highest lower-bound version from >= and > specifiers.

Parameters:

requirement (Requirement) – Parsed requirement instance.

Returns:

Highest lower bound version string, or None if missing.

Return type:

str | None

Raises:

DevtoolsError – If version parsing fails.

mafw.devtools.dependencies.freeze.iter_specifiers(requirement: Requirement) list[Specifier][source]

Return a concrete list of specifiers for the given requirement.

Parameters:

requirement (Requirement) – Parsed requirement instance.

Returns:

List of specifier objects.

Return type:

list[Specifier]

mafw.devtools.dependencies.freeze.summarize_freeze_changes(before: str, after: str) str[source]

Build a short summary for dry-run output.

Parameters:
  • before (str) – Original TOML content.

  • after (str) – Updated TOML content.

Returns:

Human-readable summary line.

Return type:

str

mafw.devtools.dependencies.freeze.update_dependency_list(dependencies: Any, *, transformer: Callable[[str], tuple[str, list[str]]], warnings: list[str], context: str) None[source]

Update a TOML list of dependency strings in-place.

Parameters:
  • dependencies (Any) – TOML array that contains dependency strings.

  • transformer (Any) – Callable applied to each dependency string.

  • warnings (list[str]) – List of warnings to append to.

  • context (str) – Human-readable location for warnings.

mafw.devtools.dependencies.freeze._FROZEN_OPERATORS: Final[set[str]] = {'<', '<=', '==', '===', '~='}

Operators that already constrain the maximum compatible version and should not be auto-frozen.