Skip to content

Navigation Menu

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Rework some "private" functions in semver.version? #309

Copy link
Copy link
Closed
@tomschr

Description

@tomschr
Issue body actions

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 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?

Metadata

Metadata

Assignees

Labels

EnhancementNot a bug, but increases or improves in value, quality, desirability, or attractivenessNot a bug, but increases or improves in value, quality, desirability, or attractivenessQuestionUnclear or open issue subject for debateUnclear or open issue subject for debate

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions

    Morty Proxy This is a proxified and sanitized view of the page, visit original site.