Thanks to visit codestin.com
Credit goes to github.com

Skip to content
Merged
Show file tree
Hide file tree
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
10 changes: 10 additions & 0 deletions changelog.d/316.trivial.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
Comparisons of :class:`~semver.version.Version` class and other
types return now a :py:const:`NotImplemented` constant instead
of a :py:exc:`TypeError` exception.

The `NotImplemented`_ section of the Python documentation recommends
returning this constant when comparing with ``__gt__``, ``__lt__``,
and other comparison operators to "to indicate that the operation is
not implemented with respect to the other type".

.. _NotImplemented: https://docs.python.org/3/library/constants.html#NotImplemented
4 changes: 1 addition & 3 deletions src/semver/version.py
Original file line number Diff line number Diff line change
Expand Up @@ -72,9 +72,7 @@ def wrapper(self: "Version", other: Comparable) -> bool:
*String.__args__, # type: ignore
)
if not isinstance(other, comparable_types):
raise TypeError(
"other type %r must be in %r" % (type(other), comparable_types)
)
return NotImplemented
return operator(self, other)

return wrapper
Expand Down