@@ -54,17 +54,20 @@ The preferred way to create a new version is with the class
5454
5555A :class: `~semver.version.Version ` instance can be created in different ways:
5656
57- * From a Unicode string ::
57+ * Without any arguments ::
5858
5959 >>> from semver.version import Version
60- >>> Version.parse("3.4.5-pre.2+build.4")
60+ >>> Version()
61+ Version(major=0, minor=0, patch=0, prerelease=None, build=None)
62+
63+ * From a Unicode string::
64+
65+ >>> Version("3.4.5-pre.2+build.4")
6166 Version(major=3, minor=4, patch=5, prerelease='pre.2', build='build.4')
62- >>> Version.parse(u"5.3.1")
63- Version(major=5, minor=3, patch=1, prerelease=None, build=None)
6467
6568* From a byte string::
6669
67- >>> Version.parse (b"2.3.4")
70+ >>> Version(b"2.3.4")
6871 Version(major=2, minor=3, patch=4, prerelease=None, build=None)
6972
7073* From individual parts by a dictionary::
@@ -100,6 +103,32 @@ A :class:`~semver.version.Version` instance can be created in different ways:
100103 >>> Version("3", "5", 6)
101104 Version(major=3, minor=5, patch=6, prerelease=None, build=None)
102105
106+ It is possible to combine, positional and keyword arguments. In
107+ some use cases you have a fixed version string, but would like to
108+ replace parts of them. For example::
109+
110+ >>> Version(1, 2, 3, major=2, build="b2")
111+ Version(major=2, minor=2, patch=3, prerelease=None, build='b2')
112+
113+ It is also possible to use a version string and replace specific
114+ parts::
115+
116+ >>> Version("1.2.3", major=2, build="b2")
117+ Version(major=2, minor=2, patch=3, prerelease=None, build='b2')
118+
119+ However, it is not possible to use a string and additional positional
120+ arguments:
121+
122+ >>> Version(" 1.2.3" , 4 )
123+ Traceback (most recent call last):
124+ ...
125+ ValueError: You cannot pass a string and additional positional arguments
126+
127+
128+
129+ Using Deprecated Functions to Create a Version
130+ ----------------------------------------------
131+
103132The old, deprecated module level functions are still available but
104133using them are discoraged. They are available to convert old code
105134to semver3.
@@ -130,17 +159,7 @@ Depending on your use case, the following methods are available:
130159 >>> semver.parse("1.2")
131160 Traceback (most recent call last):
132161 ...
133- ValueError: 1.2 is not valid SemVer string
134-
135-
136- Parsing a Version String
137- ------------------------
138-
139- "Parsing" in this context means to identify the different parts in a string.
140- Use the function :func: `Version.parse <semver.version.Version.parse> `::
141-
142- >>> Version.parse("3.4.5-pre.2+build.4")
143- Version(major=3, minor=4, patch=5, prerelease='pre.2', build='build.4')
162+ ValueError: '1.2' is not valid SemVer string
144163
145164
146165Checking for a Valid Semver Version
@@ -167,7 +186,7 @@ parts of a version:
167186
168187.. code-block :: python
169188
170- >> > v = Version.parse (" 3.4.5-pre.2+build.4" )
189+ >> > v = Version(" 3.4.5-pre.2+build.4" )
171190 >> > v.major
172191 3
173192 >> > v.minor
@@ -436,7 +455,7 @@ To compare two versions depends on your type:
436455 >>> v > "1.0"
437456 Traceback (most recent call last):
438457 ...
439- ValueError: 1.0 is not valid SemVer string
458+ ValueError: ' 1.0' is not valid SemVer string
440459
441460* **A ** :class: `Version <semver.version.Version> ` **type and a ** :func: `dict `
442461
0 commit comments