Skip to content
Back to top
View this page
Edit this page

# pontos.version package

## Submodules

- pontos.version.commands package
- pontos.version.project package
- pontos.version.schemes package
- pontos.version.helper package

exception pontos.version.VersionError

  Bases: `PontosError`

  Some error has occurred during version handling

class pontos.version.Version(original_version)

  An abstract base class for version information

  A version implementation must consider the following constraints:

  - Version strings containing -dev, and .dev are considered development versions.

  - Version strings containing +dev are not considered as development versions.

  - Development versions are are also pre releases. The following version string is a development version and a pre release: 1.2.3-alpha1-dev1

  - A version must return a pre for development versions for version strings containing a pre release version like 1.2.3-alpha1-dev1

  - A development version has no local part

  - Alpha, Beta, Release Candidate and Development versions are pre releases

  - Alpha, Beta and Release Candidate versions pre must return the following names for the first value in the tuple: alpha, beta, rc and dev

  abstract property dev: int | None

    The development number of the version.

  abstractmethod classmethod from_string(version)

    Create a version from a version string

    Parameters:

      version (str) – Version string to parse

    Raises:

      VersionError – If the version string is invalid.

    Returns:

      A new version instance

    Return type:

      Version

  abstractmethod classmethod from_version(version)

    Convert a version (if necessary)

    This method can be used to convert version instances from different versioning schemes.

    Return type:

      Version

  abstract property is_alpha_release: bool

    Whether this version is an alpha release.

  abstract property is_beta_release: bool

    Whether this version is a beta release.

  abstract property is_dev_release: bool

    Whether this version is a development release.

  abstract property is_pre_release: bool

    Whether this version is a pre-release (alpha, beta, release candidate).

  abstract property is_release_candidate: bool

    Whether this version is a release candidate.

  abstract property local: tuple[str, int] | None

    The local version segment of the version.

  abstract property major: int

    The first item of the version or `0` if unavailable.

  abstract property minor: int

    The second item of the version or `0` if unavailable.

  property parsed_version: str

    Original version string from which the version has been parsed

  abstract property patch: int

    The third item of the version or `0` if unavailable.

  abstract property pre: tuple[str, int] | None

    The pre-release segment of the version.

class pontos.version.VersionCalculator

  An abstract base class for calculating a next version from a version

  abstractmethod static next_alpha_version(current_version)

    Get the next alpha version from a valid version

    Examples

    “1.2.3” will return “1.2.4-alpha1” “1.2.3.dev1” will return “1.2.3-alpha1” “1.2.3-dev1” will return “1.2.3-alpha1” “1.2.3+dev1” will return “1.2.4-alpha1” “1.2.3-alpha1” will return “1.2.3-alpha2” “1.0.0” will return “1.0.1-alpha1” “1.0.0-a1” will return “1.0.1-alpha1” “1.0.0.dev1” will return “1.0.0-alpha1” “0.5.0-a1” will return “0.5.1-alpha1” “0.5.0.dev1” will return “0.5.0-alpha1”

    Return type:

      Version

  abstractmethod static next_beta_version(current_version)

    Get the next beta version from a valid version

    Examples

    “1.2.3” will return “1.2.4-beta1” “1.2.3.dev1” will return “1.2.3-beta1” “1.2.3-dev1” will return “1.2.3-beta1” “1.2.3+dev1” will return “1.2.4-beta1” “1.2.3-alpha1” will return “1.2.3-beta1” “1.0.0” will return “1.0.1-beta1” “1.0.0-a1” will return “1.0.1-beta1” “1.0.0.dev1” will return “1.0.0-beta1” “0.5.0-a1” will return “0.5.1-beta1” “0.5.0.dev1” will return “0.5.0-beta1”

    Return type:

      Version

  classmethod next_calendar_version(current_version)

    Find the correct next calendar version by checking latest version and the today’s date

    Raises:

      VersionError – If version is invalid.

    Return type:

      Version

  abstractmethod static next_dev_version(current_version)

    Get the next development version from a valid version

    Examples

    “1.2.3” will return “1.2.4-dev1” “1.2.3.dev1” will return “1.2.3.dev2” “1.2.3-dev1” will return “1.2.3-dev2” “1.2.3+dev1” will return “1.2.4-dev1” “1.2.3-alpha1” will return “1.2.3-alpha2-dev1” “1.0.0” will return “1.0.1-dev1” “1.0.0-a1” will return “1.0.0-a2-dev1” “1.0.0.dev1” will return “1.0.0.dev2” “0.5.0-a1” will return “0.5.0-a2-dev1” “0.5.0.dev1” will return “0.5.0.dev2”

    Return type:

      Version

  classmethod next_major_version(current_version)

    Get the next major version from a valid version

    Examples

    “1.2.3” will return “2.0.0” “1.2.3.dev1” will return “1.2.3” “1.2.3-alpha1” will return “1.2.3” “1.0.0” will return “2.0.0” “1.0.0-a1” will return “1.0.0” “1.0.0.dev1” will return “1.0.0” “0.5.0-a1” will return “1.0.0” “0.5.0.dev1” will return “1.0.0”

    Return type:

      Version

  classmethod next_minor_version(current_version)

    Get the next minor version from a valid version

    Examples

    “1.2.3” will return “1.3.0” “1.2.3.dev1” will return “1.3.0” “1.2.3-alpha1” will return “1.3.0” “1.0.0” will return “1.1.0” “1.0.0-a1” will return “1.0.0” “1.0.0.dev1” will return “1.0.0” “0.5.0-a1” will return “0.5.0” “0.5.0.dev1” will return “0.5.0”

    Return type:

      Version

  classmethod next_patch_version(current_version)

    Get the next patch version from a valid version

    Examples

    “1.2.3” will return “1.2.4” “1.2.3.dev1” will return “1.2.3” “1.2.3-dev1” will return “1.2.3” “1.2.3+dev1” will return “1.2.4” “1.2.3-alpha1” will return “1.2.3” “1.0.0” will return “1.0.1” “1.0.0-a1” will return “1.0.0” “1.0.0.dev1” will return “1.0.0” “0.5.0-a1” will return “0.5.0” “0.5.0.dev1” will return “0.5.0”

    Return type:

      Version

  abstractmethod static next_release_candidate_version(current_version)

    Get the next release candidate version from a valid version

    Examples

    “1.2.3” will return “1.2.4-rc1” “1.2.3.dev1” will return “1.2.3-rc1” “1.2.3-dev1” will return “1.2.3-rc1” “1.2.3+dev1” will return “1.2.4-rc1” “1.2.3-alpha1” will return “1.2.3-rc1” “1.0.0” will return “1.0.1-rc1” “1.0.0-a1” will return “1.0.1-rc1” “1.0.0.dev1” will return “1.0.0-rc1” “0.5.0-a1” will return “0.5.1-rc1” “0.5.0.dev1” will return “0.5.0-rc”

    Return type:

      Version

  classmethod version_from_string(version)

    Create a version from a version string

    Parameters:

      version (str) – Version string to parse

    Raises:

      VersionError – If the version string is invalid.

    Returns:

      A new version instance

    Return type:

      Version

class pontos.version.VersionUpdate(previous, new, changed_files=<factory>)

  Represents a version update from a previous version to a new version.

  If previous and new are equal the version was not updated and changed_files should be empty.

  If there is no previous version for example in an initial release previous should be None.

  Example

      from pathlib import Path
      from python.version import Version, VersionUpdate

      update = VersionUpdate(
          previous=Version("1.2.3"),
          new=Version("2.0.0"),
          changed_files=[Path("package.json"), Path("version.js")],
      )