Skip to content

Commit d38813d

Browse files
committed
Rename VersionInfo to Version to close #305
Add documentation for Version rename
1 parent 194345d commit d38813d

18 files changed

+282
-254
lines changed

README.rst

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,12 @@ A Python module for `semantic versioning`_. Simplifies comparing versions.
3030
.. |MAINT| replace:: ``maint/v2``
3131
.. _MAINT: https://github.com/python-semver/python-semver/tree/maint/v2
3232

33+
.. note::
34+
35+
The :class:`VersionInfo` has been renamed to :class:`Version`. An
36+
alias has been created to preserve compatibility but the use of the old
37+
name has been deprecated.
38+
3339
The module follows the ``MAJOR.MINOR.PATCH`` style:
3440

3541
* ``MAJOR`` version when you make incompatible API changes,
@@ -45,11 +51,11 @@ To import this library, use:
4551
>>> import semver
4652
4753
Working with the library is quite straightforward. To turn a version string into the
48-
different parts, use the ``semver.VersionInfo.parse`` function:
54+
different parts, use the ``semver.Version.parse`` function:
4955

5056
.. code-block:: python
5157
52-
>>> ver = semver.VersionInfo.parse('1.2.3-pre.2+build.4')
58+
>>> ver = semver.Version.parse('1.2.3-pre.2+build.4')
5359
>>> ver.major
5460
1
5561
>>> ver.minor
@@ -62,21 +68,21 @@ different parts, use the ``semver.VersionInfo.parse`` function:
6268
'build.4'
6369
6470
To raise parts of a version, there are a couple of functions available for
65-
you. The function ``semver.VersionInfo.bump_major`` leaves the original object untouched, but
66-
returns a new ``semver.VersionInfo`` instance with the raised major part:
71+
you. The function ``semver.Version.bump_major`` leaves the original object untouched, but
72+
returns a new ``semver.Version`` instance with the raised major part:
6773

6874
.. code-block:: python
6975
70-
>>> ver = semver.VersionInfo.parse("3.4.5")
76+
>>> ver = semver.Version.parse("3.4.5")
7177
>>> ver.bump_major()
72-
VersionInfo(major=4, minor=0, patch=0, prerelease=None, build=None)
78+
Version(major=4, minor=0, patch=0, prerelease=None, build=None)
7379
7480
It is allowed to concatenate different "bump functions":
7581

7682
.. code-block:: python
7783
7884
>>> ver.bump_major().bump_minor()
79-
VersionInfo(major=4, minor=1, patch=0, prerelease=None, build=None)
85+
Version(major=4, minor=1, patch=0, prerelease=None, build=None)
8086
8187
To compare two versions, semver provides the ``semver.compare`` function.
8288
The return value indicates the relationship between the first and second

changelog.d/305.doc.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Add note about :class:`Version` rename.

changelog.d/305.feature.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Rename :class:`VersionInfo` to :class:`Version` but keep an alias for compatibility

docs/coerce.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,18 +17,18 @@
1717

1818
def coerce(version):
1919
"""
20-
Convert an incomplete version string into a semver-compatible VersionInfo
20+
Convert an incomplete version string into a semver-compatible Version
2121
object
2222
2323
* Tries to detect a "basic" version string (``major.minor.patch``).
2424
* If not enough components can be found, missing components are
2525
set to zero to obtain a valid semver version.
2626
2727
:param str version: the version string to convert
28-
:return: a tuple with a :class:`VersionInfo` instance (or ``None``
28+
:return: a tuple with a :class:`Version` instance (or ``None``
2929
if it's not a version) and the rest of the string which doesn't
3030
belong to a basic version.
31-
:rtype: tuple(:class:`VersionInfo` | None, str)
31+
:rtype: tuple(:class:`Version` | None, str)
3232
"""
3333
match = BASEVERSION.search(version)
3434
if not match:
@@ -37,6 +37,6 @@ def coerce(version):
3737
ver = {
3838
key: 0 if value is None else value for key, value in match.groupdict().items()
3939
}
40-
ver = semver.VersionInfo(**ver)
40+
ver = semver.Version(**ver)
4141
rest = match.string[match.end() :] # noqa:E203
4242
return ver, rest

docs/semverwithvprefix.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,15 @@
1-
from semver import VersionInfo
1+
from semver import Version
22

33

4-
class SemVerWithVPrefix(VersionInfo):
4+
class SemVerWithVPrefix(Version):
55
"""
6-
A subclass of VersionInfo which allows a "v" prefix
6+
A subclass of Version which allows a "v" prefix
77
"""
88

99
@classmethod
1010
def parse(cls, version):
1111
"""
12-
Parse version string to a VersionInfo instance.
12+
Parse version string to a Version instance.
1313
1414
:param version: version string with "v" or "V" prefix
1515
:type version: str

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy