@@ -43,18 +43,14 @@ def ensure_str(s: String, encoding="utf-8", errors="strict") -> str:
4343 * `bytes` -> decoded to `str`
4444
4545 :param s: the string to convert
46- :type s: str | bytes
4746 :param encoding: the encoding to apply, defaults to "utf-8"
48- :type encoding: str
4947 :param errors: set a different error handling scheme,
5048 defaults to "strict".
5149 Other possible values are `ignore`, `replace`, and
5250 `xmlcharrefreplace` as well as any other name
5351 registered with :func:`codecs.register_error`.
54- :type errors: str
5552 :raises TypeError: if ``s`` is not str or bytes type
5653 :return: the converted string
57- :rtype: str
5854 """
5955 if isinstance (s , bytes ):
6056 s = s .decode (encoding , errors )
@@ -218,7 +214,7 @@ def build(self, value):
218214
219215 def to_tuple (self ) -> VersionTuple :
220216 """
221- Convert the VersionInfo object to a tuple.
217+ Convert the Version object to a tuple.
222218
223219 .. versionadded:: 2.10.0
224220 Renamed ``VersionInfo._astuple`` to ``VersionInfo.to_tuple`` to
@@ -233,7 +229,7 @@ def to_tuple(self) -> VersionTuple:
233229
234230 def to_dict (self ) -> VersionDict :
235231 """
236- Convert the VersionInfo object to an OrderedDict.
232+ Convert the Version object to an OrderedDict.
237233
238234 .. versionadded:: 2.10.0
239235 Renamed ``VersionInfo._asdict`` to ``VersionInfo.to_dict`` to
@@ -257,7 +253,7 @@ def to_dict(self) -> VersionDict:
257253 )
258254
259255 def __iter__ (self ) -> VersionIterator :
260- """Implement iter(self)."""
256+ """Return iter(self)."""
261257 yield from self .to_tuple ()
262258
263259 @staticmethod
@@ -300,7 +296,6 @@ def bump_minor(self) -> "Version":
300296
301297 :return: new object with the raised minor part
302298
303-
304299 >>> ver = semver.parse("3.4.5")
305300 >>> ver.bump_minor()
306301 Version(major=3, minor=5, patch=0, prerelease=None, build=None)
@@ -313,8 +308,7 @@ def bump_patch(self) -> "Version":
313308 Raise the patch part of the version, return a new object but leave self
314309 untouched.
315310
316- :return: new object with the raised patch part
317-
311+ :return: new object with the raised patch part
318312
319313 >>> ver = semver.parse("3.4.5")
320314 >>> ver.bump_patch()
@@ -328,7 +322,7 @@ def bump_prerelease(self, token: str = "rc") -> "Version":
328322 Raise the prerelease part of the version, return a new object but leave
329323 self untouched.
330324
331- :param token: defaults to 'rc'
325+ :param token: defaults to ``rc``
332326 :return: new object with the raised prerelease part
333327
334328 >>> ver = semver.parse("3.4.5")
@@ -345,7 +339,7 @@ def bump_build(self, token: str = "build") -> "Version":
345339 Raise the build part of the version, return a new object but leave self
346340 untouched.
347341
348- :param token: defaults to ' build'
342+ :param token: defaults to `` build``
349343 :return: new object with the raised build part
350344
351345 >>> ver = semver.parse("3.4.5-rc.1+build.9")
@@ -365,7 +359,6 @@ def compare(self, other: Comparable) -> int:
365359 :return: The return value is negative if ver1 < ver2,
366360 zero if ver1 == ver2 and strictly positive if ver1 > ver2
367361
368-
369362 >>> semver.compare("2.0.0")
370363 -1
371364 >>> semver.compare("1.0.0")
@@ -481,14 +474,17 @@ def __getitem__(
481474 self , index : Union [int , slice ]
482475 ) -> Union [int , Optional [str ], Tuple [Union [int , str ], ...]]:
483476 """
484- self.__getitem__(index) <==> self[index] Implement getitem. If the part
485- requested is undefined, or a part of the range requested is undefined,
486- it will throw an index error. Negative indices are not supported.
477+ self.__getitem__(index) <==> self[index] Implement getitem.
478+
479+ If the part requested is undefined, or a part of the range requested
480+ is undefined, it will throw an index error.
481+ Negative indices are not supported.
487482
488483 :param Union[int, slice] index: a positive integer indicating the
489484 offset or a :func:`slice` object
490485 :raises IndexError: if index is beyond the range or a part is None
491486 :return: the requested part of the version at position index
487+
492488 >>> ver = semver.Version.parse("3.4.5")
493489 >>> ver[0], ver[1], ver[2]
494490 (3, 4, 5)
@@ -519,7 +515,6 @@ def __repr__(self) -> str:
519515 return "%s(%s)" % (type (self ).__name__ , s )
520516
521517 def __str__ (self ) -> str :
522- """str(self)"""
523518 version = "%d.%d.%d" % (self .major , self .minor , self .patch )
524519 if self .prerelease :
525520 version += "-%s" % self .prerelease
@@ -533,7 +528,9 @@ def __hash__(self) -> int:
533528 def finalize_version (self ) -> "Version" :
534529 """
535530 Remove any prerelease and build metadata from the version.
531+
536532 :return: a new instance with the finalized version string
533+
537534 >>> str(semver.Version.parse('1.2.3-rc.5').finalize_version())
538535 '1.2.3'
539536 """
@@ -545,12 +542,12 @@ def match(self, match_expr: str) -> bool:
545542 Compare self to match a match expression.
546543
547544 :param match_expr: operator and version; valid operators are
548- < smaller than
549- > greater than
550- >= greator or equal than
551- <= smaller or equal than
552- == equal
553- != not equal
545+ ``<``` smaller than
546+ ``>`` greater than
547+ ``>=`` greator or equal than
548+ ``<=`` smaller or equal than
549+ ``==`` equal
550+ ``!=`` not equal
554551 :return: True if the expression matches the version, otherwise False
555552
556553 >>> semver.Version.parse("2.0.0").match(">=1.0.0")
@@ -589,18 +586,18 @@ def match(self, match_expr: str) -> bool:
589586 @classmethod
590587 def parse (cls , version : String ) -> "Version" :
591588 """
592- Parse version string to a VersionInfo instance.
589+ Parse version string to a Version instance.
593590
594591 .. versionchanged:: 2.11.0
595592 Changed method from static to classmethod to
596593 allow subclasses.
597594
598595 :param version: version string
599- :return: a :class:`VersionInfo ` instance
596+ :return: a new :class:`Version ` instance
600597 :raises ValueError: if version is invalid
601598
602599 >>> semver.Version.parse('3.4.5-pre.2+build.4')
603- VersionInfo (major=3, minor=4, patch=5, \
600+ Version (major=3, minor=4, patch=5, \
604601 prerelease='pre.2', build='build.4')
605602 """
606603 version_str = ensure_str (version )
@@ -624,15 +621,15 @@ def replace(self, **parts: Union[int, Optional[str]]) -> "Version":
624621 ``major``, ``minor``, ``patch``, ``prerelease``, or ``build``
625622 :return: the new :class:`Version` object with the changed
626623 parts
627- :raises TypeError: if ``parts`` contains invalid keys
624+ :raises TypeError: if ``parts`` contain invalid keys
628625 """
629626 version = self .to_dict ()
630627 version .update (parts )
631628 try :
632629 return Version (** version ) # type: ignore
633630 except TypeError :
634631 unknownkeys = set (parts ) - set (self .to_dict ())
635- error = "replace() got %d unexpected keyword " " argument(s): %s" % (
632+ error = "replace() got %d unexpected keyword argument(s): %s" % (
636633 len (unknownkeys ),
637634 ", " .join (unknownkeys ),
638635 )
0 commit comments