You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Rework some "private" functions in semver.version? #309
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 the Version/VersionInfo class.
ensure_str: a function to make sure we have always (Unicode) strings regardless if we pass a str or bytes type. Used in semver.version.Version.parse method.
cmd: a function that is used inside _nat_cmp and Version.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 into semver.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?
Activity
[-]Make some function of semver.version "private"?[/-][+]Rework some "private" functions in semver.version?[/+]Fix python-semver#309: Make some functions private
Fix python-semver#309: Make some functions private
tlaferriere commentedon Nov 10, 2020
I've got no objections on this. This is going to make the API much cleaner.
Fix python-semver#309: Make some functions private
Merge pull request #320 from tomschr/feature/309-private-functions