Versioning

Versioning assistance utilities.

exception pypreset.versioning.VersioningError[source]

Bases: Exception

Error raised for versioning failures.

exception pypreset.versioning.CommandFailure[source]

Bases: VersioningError

Error raised when a command fails.

Parameters:
command: list[str]
returncode: int | None
stdout: str
stderr: str
__init__(command, returncode, stdout, stderr)
Parameters:
Return type:

None

class pypreset.versioning.CommandRunner[source]

Bases: Protocol

Protocol for running shell commands.

run(args, *, check=True)[source]

Run a command and return the completed process.

Parameters:
Return type:

CompletedProcess[str]

__init__(*args, **kwargs)
class pypreset.versioning.SubprocessRunner[source]

Bases: object

Subprocess-backed command runner.

Parameters:

cwd (Path)

__init__(cwd)[source]
Parameters:

cwd (Path)

Return type:

None

run(args, *, check=True)[source]

Run a command with subprocess.

Parameters:
Return type:

CompletedProcess[str]

pypreset.versioning.sync_server_file(server_file, version)[source]

Update all "version": "..." values in a JSON server file.

Reads the file as text and performs a regex replacement so the rest of the file (formatting, comments, trailing newline) is preserved exactly.

Returns the number of replacements made.

Parameters:
Return type:

int

class pypreset.versioning.VersioningAssistant[source]

Bases: object

Implements versioning workflows inspired by the project’s Justfile.

Parameters:
__init__(project_dir, runner=None, *, preflight=True, server_file=None)[source]
Parameters:
Return type:

None

release(bump)[source]

Bump version, commit, tag, push, and create a GitHub release.

Parameters:

bump (str)

Return type:

str

release_version(version)[source]

Use an explicit version, then commit, tag, push, and release.

Parameters:

version (str)

Return type:

str

rerun(version)[source]

Re-tag and push an existing version.

Parameters:

version (str)

Return type:

str

rerelease(version)[source]

Delete and recreate a GitHub release for a version.

Parameters:

version (str)

Return type:

str