Skip to content

Add version information in some functions #230

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Mar 19, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
41 changes: 28 additions & 13 deletions semver.py
Original file line number Diff line number Diff line change
Expand Up @@ -307,8 +307,12 @@ def parse(version):
return parse_version_info(version)

def replace(self, **parts):
"""Replace one or more parts of a version and return a new
:class:`semver.VersionInfo` object, but leave self untouched
"""
Replace one or more parts of a version and return a new
:class:`semver.VersionInfo` object, but leave self untouched

.. versionadded:: 2.9.0
Added :func:`VersionInfo.replace`

:param dict parts: the parts to be updated. Valid keys are:
``major``, ``minor``, ``patch``, ``prerelease``, or ``build``
Expand All @@ -333,6 +337,8 @@ def isvalid(cls, version):
"""
Check if the string is a valid semver version.

.. versionadded:: 2.9.1

:param str version: the version string to check
:return: True if the version string is a valid semver version, False
otherwise.
Expand All @@ -357,6 +363,9 @@ def parse_version_info(version):
"""
Parse version string to a VersionInfo instance.

.. versionadded:: 2.7.2
Added :func:`parse_version_info`

:param version: version string
:return: a :class:`VersionInfo` instance
:rtype: :class:`VersionInfo`
Expand Down Expand Up @@ -433,7 +442,7 @@ def _compare_by_keys(d1, d2):

def compare(ver1, ver2):
"""
Compare two versions.
Compare two versions strings.

:param ver1: version string 1
:param ver2: version string 2
Expand All @@ -456,7 +465,7 @@ def compare(ver1, ver2):

def match(version, match_expr):
"""
Compare two versions through a comparison.
Compare two versions strings through a comparison.

:param str version: a version string
:param str match_expr: operator and version; valid operators are
Expand Down Expand Up @@ -505,7 +514,7 @@ def match(version, match_expr):

def max_ver(ver1, ver2):
"""
Returns the greater version of two versions.
Returns the greater version of two versions strings.

:param ver1: version string 1
:param ver2: version string 2
Expand All @@ -524,7 +533,7 @@ def max_ver(ver1, ver2):

def min_ver(ver1, ver2):
"""
Returns the smaller version of two versions.
Returns the smaller version of two versions strings.

:param ver1: version string 1
:param ver2: version string 2
Expand All @@ -543,7 +552,7 @@ def min_ver(ver1, ver2):

def format_version(major, minor, patch, prerelease=None, build=None):
"""
Format a version according to the Semantic Versioning specification.
Format a version string according to the Semantic Versioning specification.

:param int major: the required major part of a version
:param int minor: the required minor part of a version
Expand Down Expand Up @@ -582,7 +591,7 @@ def _increment_string(string):

def bump_major(version):
"""
Raise the major part of the version.
Raise the major part of the version string.

:param: version string
:return: the raised version string
Expand All @@ -597,7 +606,7 @@ def bump_major(version):

def bump_minor(version):
"""
Raise the minor part of the version.
Raise the minor part of the version string.

:param: version string
:return: the raised version string
Expand All @@ -612,7 +621,7 @@ def bump_minor(version):

def bump_patch(version):
"""
Raise the patch part of the version.
Raise the patch part of the version string.

:param: version string
:return: the raised version string
Expand All @@ -627,7 +636,7 @@ def bump_patch(version):

def bump_prerelease(version, token="rc"):
"""
Raise the prerelease part of the version.
Raise the prerelease part of the version string.

:param version: version string
:param token: defaults to 'rc'
Expand All @@ -648,7 +657,7 @@ def bump_prerelease(version, token="rc"):

def bump_build(version, token="build"):
"""
Raise the build part of the version.
Raise the build part of the version string.

:param version: version string
:param token: defaults to 'build'
Expand All @@ -671,7 +680,10 @@ def bump_build(version, token="build"):

def finalize_version(version):
"""
Remove any prerelease and build metadata from the version.
Remove any prerelease and build metadata from the version string.

.. versionadded:: 2.7.9
Added :func:`finalize_version`

:param version: version string
:return: the finalized version string
Expand Down Expand Up @@ -830,6 +842,9 @@ def replace(version, **parts):
"""
Replace one or more parts of a version and return the new string.

.. versionadded:: 2.9.0
Added :func:`replace`

:param str version: the version string to replace
:param dict parts: the parts to be updated. Valid keys are:
``major``, ``minor``, ``patch``, ``prerelease``, or ``build``
Expand Down