Skip to content

Version Bump Script API

bump_version

Interactive version bumper for YYYY.MM.DD style versions.

This script updates: - pyproject.toml -> [project].version - src/tdmake_gui_wrapper/init.py -> version

Version format: - YYYY.MM.DD - YYYY.MM.DD.N (optional revision for same-day releases)

VersionParts dataclass

VersionParts(year: int, month: int, day: int, revision: int | None = None)

Structured representation of a calendar-version string.

Parameters:

Name Type Description Default
year int

Four-digit year component.

required
month int

Month component in the range 1-12.

required
day int

Day-of-month component.

required
revision int or None

Optional same-day revision suffix.

None

as_date property

as_date: date

Convert the version date components into a :class:datetime.date.

Returns:

Type Description
date

Date instance built from year, month, and day.

to_string

to_string() -> str

Serialize the version to YYYY.MM.DD (with optional revision).

Returns:

Type Description
str

Calendar-version string using zero-padded date components.

compute_next_version

compute_next_version(current: VersionParts, choice: str) -> VersionParts

Compute the next version according to an increment strategy.

Parameters:

Name Type Description Default
current VersionParts

Current parsed version components.

required
choice str

Increment mode as returned by :func:prompt_choice.

required

Returns:

Type Description
VersionParts

New version components after applying the selected increment rule.

main

main() -> None

Run the interactive version bump workflow.

Notes

This function reads the current version, prompts for an increment strategy, asks for confirmation, and writes updated values to both pyproject.toml and src/tdmake_gui_wrapper/__init__.py.

parse_version

parse_version(value: str) -> VersionParts | None

Parse a version string into structured components.

Parameters:

Name Type Description Default
value str

Version string expected in YYYY.MM.DD or YYYY.MM.DD.N format.

required

Returns:

Type Description
VersionParts or None

Parsed version object when valid; otherwise None.

prompt_choice

prompt_choice() -> str

Prompt the user to choose which version component to increment.

Returns:

Type Description
str

One of "1", "2", "3", or "4".

read_current_version

read_current_version() -> str

Read the project version from pyproject.toml.

Returns:

Type Description
str

Current version string from [project].version.

Raises:

Type Description
RuntimeError

If no version field can be located.

replace_version_in_file

replace_version_in_file(path: Path, pattern: str, new_version: str) -> None

Replace the first version assignment matching a regex pattern.

Parameters:

Name Type Description Default
path Path

File to update.

required
pattern str

Regular-expression pattern containing a first capture group for the left side of the assignment.

required
new_version str

Version string to write.

required

Raises:

Type Description
RuntimeError

If exactly one replacement cannot be performed.

options: members: true show_root_full_path: false