mafw.devtools.release.versioning

Version parsing, classification, and bumping utilities for MAFw releases.

This module contains the business logic for version string parsing, classification, validation, and the Hatch-based version bumping workflow.

Module Attributes

VALID_HATCH_SEGMENTS

Allowed Hatch version segments supported by this script.

VERSION_PATTERN

Regular expression used to parse local version strings (stable/alpha/beta/rc).

STABLE_TAG_PATTERN

Regular expression used to identify stable git tags in the form vX.Y.Z.

ABOUT_FILE

Path to the version source file managed by hatch version.

NOTICE_FILE

Path to the notice file containing the public project version.

NOTICE_VERSION_PATTERN

Pattern used to update the version block in NOTICE.txt.

DOC_TARGET_VERSION_PATTERN

Pattern used to validate documentation target version strings.

VersionKind

Supported release kinds used to drive changelog and release-note behavior.

Functions

compute_doc_target_version(version, segments)

Determine the new documentation target version for a release.

next_minor_version(version)

Compute the next major.minor target from a release version.

validate_doc_target_version(version)

Validate a documentation target version string.

mafw.devtools.release.versioning._parse_major_minor(version: str) tuple[int, int][source]

Parse a version string in major.minor form.

Parameters:

version (str) – Version string to parse.

Returns:

Parsed major and minor components.

Return type:

tuple[int, int]

Raises:

DevtoolsError – If the version format is invalid.

mafw.devtools.release.versioning.compute_doc_target_version(version: str, segments: str, override: str | None = None) str[source]

Determine the new documentation target version for a release.

Parameters:
  • version (str) – Bumped release version.

  • segments (str) – Normalized Hatch selector used for the release.

  • override (str | None) – Optional explicit documentation target override.

Returns:

Documentation target version in major.minor form.

Return type:

str

mafw.devtools.release.versioning.next_minor_version(version: str) str[source]

Compute the next major.minor target from a release version.

Parameters:

version (str) – Release version in major.minor.micro form.

Returns:

Next documentation target version.

Return type:

str

mafw.devtools.release.versioning.validate_doc_target_version(version: str) str[source]

Validate a documentation target version string.

Parameters:

version (str) – Version string to validate.

Returns:

Normalized version string.

Return type:

str

Raises:

DevtoolsError – If the version format is invalid.

mafw.devtools.release.versioning.ABOUT_FILE = PosixPath('src/mafw/__about__.py')

Path to the version source file managed by hatch version.

mafw.devtools.release.versioning.DOC_TARGET_VERSION_PATTERN = re.compile('^\\d+\\.\\d+$')

Pattern used to validate documentation target version strings.

mafw.devtools.release.versioning.NOTICE_FILE = PosixPath('NOTICE.txt')

Path to the notice file containing the public project version.

mafw.devtools.release.versioning.NOTICE_VERSION_PATTERN = re.compile('MAFw - Modular Analysis Framework\\n\\nversion:\\s*V[0-9]+\\.[0-9]+\\.[0-9]+(?:[-a-zA-Z0-9\\.\\-_]+)?', re.MULTILINE)

Pattern used to update the version block in NOTICE.txt.

mafw.devtools.release.versioning.STABLE_TAG_PATTERN = re.compile('^v(?P<major>\\d+)\\.(?P<minor>\\d+)\\.(?P<micro>\\d+)$')

Regular expression used to identify stable git tags in the form vX.Y.Z.

mafw.devtools.release.versioning.VALID_HATCH_SEGMENTS: Final[tuple[str, ...]] = ('major', 'minor', 'micro', 'rc', 'alpha', 'beta', 'release')

Allowed Hatch version segments supported by this script.

mafw.devtools.release.versioning.VERSION_PATTERN = re.compile('^(?P<major>\\d+)\\.(?P<minor>\\d+)\\.(?P<micro>\\d+)(?:(?P<suffix>rc|a|b)(?P<suffix_num>\\d+))?$')

Regular expression used to parse local version strings (stable/alpha/beta/rc).

mafw.devtools.release.versioning.VersionKind

Supported release kinds used to drive changelog and release-note behavior.

alias of Literal[‘stable’, ‘rc’, ‘alpha’, ‘beta’]