torchoutil.pyoutil.semver module

class Version(
version: Version,
/,
)[source]
class Version(
version_str: str,
/,
)
class Version(
version_dict: Mapping[str, int | str | None | List[int | str]],
/,
)
class Version(
version_tuple: Iterable[int | str | None | List[int | str]],
/,
)
class Version(
major: int,
minor: int,
patch: int,
prerelease: int | str | None | List[int | str] = None,
buildmetadata: int | str | None | List[int | str] = None,
)

Bases: object

Version utility class following Semantic Versioning (SemVer) spec.

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

buildmetadata: int | str | None | List[int | str]
classmethod from_dict(
version_dict: Mapping[str, int | str | None | List[int | str]],
) Version[source]
classmethod from_str(
version_str: str,
) Version[source]
classmethod from_tuple(
version_tuple: Iterable[int | str | None | List[int | str]],
) Version[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[int | str]
classmethod python(
releaselevel_in_metadata: bool = False,
) Version[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[int | str]] | Tuple[int, int, int, int | str | None | List[int | str], int | str | None | List[int | str]][source]
without_buildmetadata() Version[source]
without_prerelease() Version[source]
class VersionDict(
*args,
**kwargs,
)[source]

Bases: dict

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