Skip to content

Fix #236: add missing deprecated functions #239

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Apr 23, 2020

Conversation

tomschr
Copy link
Member

@tomschr tomschr commented Apr 21, 2020

This PR fixes #236 and contains the following changes:

Deprecate:

  • semver.compare -> semver.VersionInfo.compare
  • semver.match -> semver.VersionInfo.match

Change:

  • Implementation of semver.max_ver and semver.min_ver

The implementation in this PR is a minimal implementation. I could have done more, but I would like to hear your opinion. I have two questions:

@python-semver/reviewers What do you think?

Deprecate:

* `semver.compare` -> `semver.VersionInfo.compare`
* `semver.match` -> `semver.VersionInfo.match`

Change:

* Implementation of `semver.max_ver` and `semver.min_ver`
@tomschr tomschr self-assigned this Apr 21, 2020
@tomschr tomschr added the Question Unclear or open issue subject for debate label Apr 21, 2020
@tomschr
Copy link
Member Author

tomschr commented Apr 21, 2020

I've found out a method to get rid of _compare_by_keys alltogether. The algorithm is hidden in the VersionInfo.compare method now. However, that would influence the comparison operators somehow too.

For example, rewriting the __eq__ method with this compare method, it ends up like this:

def __eq__(self, other):
    return self.compare(other) == 0

IMHO this is much nicer than the original one:

def __eq__(self, other):
    return _compare_by_keys(self.to_dict(), _to_dict(other)) == 0

The above method makes the _to_dict() function also obsolete.

The VersionInfo.compare method take into account if other is another VersionInfo instance, a dict, a tuple/list, or a string.

See commit 4482f8c. Maybe this change should go into another, separate PR?

tomschr added 2 commits April 21, 2020 18:27
* Call self.compare(other) in all comparison operators.
* Make sure, "other" is a compatible type (VersionInfo,
  dict, list, tuple, or string)
@tomschr
Copy link
Member Author

tomschr commented Apr 22, 2020

If nobody objects, I would merge it tomorrow. 😉

@tomschr tomschr merged commit d69e7c4 into python-semver:master Apr 23, 2020
@tomschr tomschr deleted the bugfix/236-deprecate-others branch April 23, 2020 17:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Question Unclear or open issue subject for debate
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Deprecate missing module-level functions (like semver.compare, semver.match, ...)
1 participant