Skip to content

Navigation Menu

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit b0f854d

Browse filesBrowse files
tlaferrieretomschr
andcommitted
Create semver package
* Bump the dev part to "dev.2" * Add stubby setup.py file for compatibility with python 3.6 * Deprecate cli functions imported from root * Revert to `pysemver` as console script. * Refactor __main__.py * add type hints for correctness * Rename VersionInfo to Version to close #305 * Refactor and integrate suggestion from @tomschr * Create :file:`src/semver/cli.py` for all CLI methods * Create :file:`src/semver/_deprecated.py` for the ``deprecated`` decorator and other deprecated functions * Create :file:`src/semver/__main__.py` to allow calling the CLI using :command:`python -m semver` * Create :file:`src/semver/_types.py` to hold type aliases * Create :file:`src/semver/version.py` to hold the :class:`VersionInfo` class and its utility functions * Create :file:`src/semver/__about__.py` for all the metadata variables * Adapt infrastructure code to the new project layout. * Replace :file:`setup.py` with :file:`setup.cfg` because the :file:`setup.cfg` is easier to use * Adapt documentation code snippets where needed * Adapt tests * Changed the ``deprecated`` to hardcode the ``semver`` package name in the warning. * Change path for docformatter and run it. * Remove pyi inclusion from black sine we aren't using them * Split up changelog to make more sense. * Add documentation for Version rename * Increase coverage to 100% in non-deprecated parts. * Update changelog.d/169.feature.rst Co-authored-by: Thomas Laferriere <t.laferriere@hotmail.ca> Co-authored-by: Tom Schraitle <tomschr@users.noreply.github.com>
1 parent ddf2b30 commit b0f854d
Copy full SHA for b0f854d

33 files changed

+1611
-1509
lines changed

‎README.rst

Copy file name to clipboardExpand all lines: README.rst
+13-7Lines 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/169.deprecation.rst

Copy file name to clipboard
+1Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Deprecate CLI functions not imported from ``semver.cli``.

‎changelog.d/169.feature.rst

Copy file name to clipboard
+10Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
Create semver package and split code among different modules in the packages.
2+
3+
* Remove :file:`semver.py`
4+
* Create :file:`src/semver/__init__.py`
5+
* Create :file:`src/semver/cli.py` for all CLI methods
6+
* Create :file:`src/semver/_deprecated.py` for the ``deprecated`` decorator and other deprecated functions
7+
* Create :file:`src/semver/__main__.py` to allow calling the CLI using :command:`python -m semver`
8+
* Create :file:`src/semver/_types.py` to hold type aliases
9+
* Create :file:`src/semver/version.py` to hold the :class:`Version` class (old name :class:`VersionInfo`) and its utility functions
10+
* Create :file:`src/semver/__about__.py` for all the metadata variables

‎changelog.d/169.trivial.rst

Copy file name to clipboard
+8Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
Adapted infrastructure code to the new project layout.
2+
3+
* Replace :file:`setup.py` with :file:`setup.cfg` because the :file:`setup.cfg` is easier to use
4+
* Adapt documentation code snippets where needed
5+
* Adapt tests
6+
* Changed the ``deprecated`` to hardcode the ``semver`` package name in the warning.
7+
8+
Increase coverage to 100% for all non-deprecated APIs

‎changelog.d/305.doc.rst

Copy file name to clipboard
+1Lines 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

Copy file name to clipboard
+1Lines 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

Copy file name to clipboardExpand all lines: docs/coerce.py
+4-4Lines 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/conf.py

Copy file name to clipboardExpand all lines: docs/conf.py
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
import os
2020
import sys
2121

22-
sys.path.insert(0, os.path.abspath(".."))
22+
sys.path.insert(0, os.path.abspath("../src/"))
2323

2424
from semver import __version__ # noqa: E402
2525

‎docs/semverwithvprefix.py

Copy file name to clipboardExpand all lines: docs/semverwithvprefix.py
+4-4Lines 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 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.