Description
Situation
Currently, we have the following module level functions inside semver.version
:
-
comparator
: a decorator that wraps a version binary operator method to allow type checks. This is only used in theVersion
/VersionInfo
class. -
ensure_str
: a function to make sure we have always (Unicode) strings regardless if we pass a str or bytes type. Used insemver.version.Version.parse
method. -
cmd
: a function that is used inside_nat_cmp
andVersion.compare
.
Proposed Solution
IMHO the above function shouldn't be part of our public API as they are hardly used outside of semver. Their use cases are very limited. Additionally, we should discourage using these functions in user's code as they mainly act as helper functions for semver's Version
class.
As such, I propose:
-
Rename the above function and add a
_
(underscore) prefix. This marks this name "private" and therefore it is not part of the public API anymore. -
Remove the function
ensure_str
. It was introduced just as a compatibility layer for Python2/3. IMHO it is better to integrate the code directly intosemver.version.Version.parse
. -
If possible and feasible, move
cmd
and_nat_cmd
into the Version class.
As we are going to publish a new major release, I think this is a good opportunity to tackle this.
@python-semver/reviewers @tlaferriere what do you think? Any objections?