Skip to content

Deprecate max_ver and min_ver #264

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

Conversation

tlaferriere
Copy link
Contributor

This could close #160 .

As I said in this comment, this PR will deprecate functions that could be useful as a shortcut.
As you can see in the new examples in the documentation, it is quite a mouthful to find the maximum of two version strings.

As an alternative to this we could keep max_ver and min_ver as utility functions that automatically convert from whatever supported types we have, passes them to max or min then converts back into the input types to return them.

Copy link
Member

@tomschr tomschr left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @tlaferriere, this is great! 👍 You even fix my bad typos. 😄 Thank you! 👍

Apart from the minor suggestions below, I have only one small wish in regards to documentation. My idea would be to distinguish two use cases (explained with maximum/highest values, the same applies for minimum/lowest values of course too):

  • Getting the highest version number from VersionInfo instances
    => we don't need max_ver, we can use the builtin max.

  • Getting the highest version number from version strings
    => we need max_ver. Additionally, we could mention an alternative with map like this:

    str(max(map(semver.VersionInfo.parse, ['1.1.0', '1.2.0', '2.1.0', '0.5.10', '0.4.99'])))

I would suggest to create (maybe?) a list which describe these two use cases.

However, there is one subtle thing: the different signatures between max and max_ver. Currently, the latter accepts only two versions whereas max can be feed with arbitrary numbers of versions.

If the developer has more than two versions to compare, the documentation should mention the alternative method with map.

Maybe we should fix the signature of max_ver/ min_ver and allow arbitrary numbers of versions to compare. However, I think, this is probably out of scope for this PR. Better we keep this PR short.

@tomschr
Copy link
Member

tomschr commented Jun 12, 2020

I forget to add another idea: could you add the two functions into the "Replacing Deprecated Functions" section? See file docs/usage.rst, line 542. Thanks! 👍

@tlaferriere
Copy link
Contributor Author

@tomschr before we go down this rabbit hole any more than we should, can you address this please?

tlaferriere and others added 8 commits June 13, 2020 09:26
Co-authored-by: Tom Schraitle <tomschr@users.noreply.github.com>
I am fairly confident this is correct and I think it should bedazzle any native English speaker with an appreciation of literature.
… min. Keep the old way of doing for reference.
@tlaferriere tlaferriere force-pushed the 160-deprecate_max_ver_min_ver branch from 0547aba to 48f92c6 Compare June 13, 2020 13:48
Co-authored-by: Tom Schraitle <tomschr@users.noreply.github.com>
@tomschr
Copy link
Member

tomschr commented Jun 15, 2020

@tlaferriere Could you add the issue and pr number in the CHANGELOG.rst file? I'd suggest to add the following line to the Removals section:

* :gh:`160` (:pr:`264`): Output DeprecationWarning for ``semver.max_ver`` and ``semver.min_ver``.

(Just an example, if you have better wording feel free to change it.)

Copy link
Member

@tomschr tomschr left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just found a minor thing in the documentation.

Furthermore, I think, we should test the two deprecated functions if they raise a DeprecationWarning. Could you add an example into the test_should_raise_deprecation_warnings function? Shouldn't be very complicated, just two lines.

After that, I think, we can merge it to master. 👍

Co-authored-by: Tom Schraitle <tomschr@users.noreply.github.com>
@tlaferriere
Copy link
Contributor Author

Could you add the issue and pr number in the CHANGELOG.rst file? I'd suggest to add the following line to the Removals section:

Sure!

While we're at it, I find that the name Removals might be a bit misleading since this is not a major release (yet 😉). Maybe renaming it to Deprecations would be nicer? It would also increase the importance of this section once we do remove things in version 3.0 (or 3.1).
Also it would make it DRYer since all we would have to add now is the issue and PR number and the name of the deprecated functions.

@tomschr
Copy link
Member

tomschr commented Jun 15, 2020

While we're at it, I find that the name Removals might be a bit misleading since this is not a major release (yet ). Maybe renaming it to Deprecations would be nicer?

You can read my mind! 😆 After I've wrote my message, I thought the same but didn't change it, unfortunately.

So, yes please! Go ahead and use Deprecations. 👍

@tlaferriere
Copy link
Contributor Author

I also went ahead and removed empty sections in the changelog, figured it would look cleaner like this.

@tomschr
Copy link
Member

tomschr commented Jun 15, 2020

Thank you Thomas. Much appreciated! 👍

As I've mentioned in #264 (comment), we should add the two deprecated functions also in the section Replacing Deprecated Functions. The list is sorted, so I'd suggest to add it between semver.format_version and semver.parse. Ok?

I think, that will complete it and we can merge it to master. 😉

@tomschr
Copy link
Member

tomschr commented Jun 15, 2020

Oh, by the way: I plan to release 2.10.2 when this is merged.

Co-authored-by: Tom Schraitle <tomschr@users.noreply.github.com>
@tlaferriere
Copy link
Contributor Author

I'm out for a few hours, if there are any more typos go ahead and fix them so you can merge this soon.

@tomschr
Copy link
Member

tomschr commented Jun 15, 2020

@tlaferriere! I think, it's in a state now that we can merge it to master. Haven't found any further issues.

Thank you very much for all your efforts! 👍 Will merge it.

@tomschr tomschr merged commit 772a7a6 into python-semver:master Jun 15, 2020
@tlaferriere tlaferriere deleted the 160-deprecate_max_ver_min_ver branch June 15, 2020 17:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Deprecate min_ver/max_ver and use builtin max()/min() functions
2 participants