pythonwrench.semver module

class pythonwrench.semver.Version(version: Self, /)[source]
class pythonwrench.semver.Version(version_str: str, /)
class pythonwrench.semver.Version(version_dict: Mapping[str, int | str | None | list[str | int]], /)
class pythonwrench.semver.Version(version_tuple: tuple[int | str | None | list[str | int], ...], /)
class pythonwrench.semver.Version(major: int, minor: int, patch: int, prerelease: int | str | None | list[str | int] = None, buildmetadata: int | str | None | list[str | int] = None)

Bases: object

Version utility class following Semantic Versioning (SemVer) spec.

Version format is: MAJOR.MINOR.PATCH[-PRERELEASE][+BUILDMETADATA]

Based on https://semver.org/ version 2.0.0.

buildmetadata : int | str | None | List[str | int]
equals(other: Version | str | Mapping[str, int | str | None | list[str | int]] | tuple[int | str | None | list[str | int], ...], *, ignore_buildmetadata: bool = False) bool[source]
classmethod from_dict(version_dict: Mapping[str, int | str | None | list[str | int]]) Self[source]
classmethod from_str(version_str: str) Self[source]
classmethod from_tuple(version_tuple: tuple[int | str | None | list[str | int], ...]) Self[source]
major : int
property micro : int

Getter alias of ‘patch’.

minor : int
next_major(keep_prerelease: bool = False, keep_buildmetadata: bool = False) Version[source]
next_minor(keep_prerelease: bool = False, keep_buildmetadata: bool = False) Version[source]
next_patch(keep_prerelease: bool = False, keep_buildmetadata: bool = False) Version[source]
patch : int
prerelease : int | str | None | List[str | int]
classmethod python(releaselevel_in_metadata: bool = False) Self[source]

Create an instance of Version with Python version.

Note: Python ‘micro’ value is mapped to ‘patch’.

to_dict(exclude_none: bool = True) VersionDict[source]
to_str() str[source]
to_tuple(exclude_none: bool = True) tuple[int, int, int] | tuple[int, int, int, int | str | None | list[str | int]] | tuple[int, int, int, int | str | None | list[str | int], int | str | None | list[str | int]][source]
without_buildmetadata() Version[source]
without_prerelease() Version[source]
class pythonwrench.semver.VersionDict[source]

Bases: TypedDict

TypedDict which represents a Version.

buildmetadata : NotRequired[int | str | None | List[str | int]]
major : int
minor : int
patch : int
prerelease : NotRequired[int | str | None | List[str | int]]