Skip to content

Support matching 'equal' when no operator is provided #362

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
Jul 4, 2022
Merged

Support matching 'equal' when no operator is provided #362

merged 3 commits into from
Jul 4, 2022

Conversation

jmi2k
Copy link
Contributor

@jmi2k jmi2k commented Jul 3, 2022

This makes it easier to work with user-supplied versions, as they may omit the comparison operator and just specify which version they want to select. Equality comparison is a sane default behavior.

@tomschr
Copy link
Member

tomschr commented Jul 3, 2022

Hi @jmi2k! Thanks for your contribution, very much appreciated. 👍 🚀

Your implementation looks good, I only have two wishes to complete it:

  1. Amend the documentation.
    The documentation should explain this new functionality too. You could add it to the section Comparing Versions through an Expression. Find the source code in docs/usage/compare-versions-through-expression.rst.
    Could you amend the doc and add a short example? Bonus points if you could give or explain the differences to Version.parse("a.b.c") == Version.parse("d.e.f"). What approach do we want to recommend to our developers? (The Zen of Python, states, "There should be one-- and preferably only one --obvious way to do it.")
  2. Create a changelog entry
    Add a short snippet which explains your addition (also mentioning this pull request number). You can find the details how to create such an entry in the section Adding a Changelog Entry.

Many thanks!

@jmi2k
Copy link
Contributor Author

jmi2k commented Jul 3, 2022

First of all, thanks for the in-depth response! I highly appreciate it, as I was kinda lost about how to add that changelog entry.

Now I think I have everything in place. The rationale behind this change is that I'm building a plugin dependency system for some in-house tool, and as you will know for sure it's pretty common to specify just the version as an exact dependency. As for now, I've written code around the match to patch the equality operator in when no operator is provided, but I feet like it's more elegant for the library to handle that case too (as the changes required were minimal).

If you think I should change anything else, please don't hesitate to tell me!

@tomschr
Copy link
Member

tomschr commented Jul 4, 2022

Thanks @jmi2k, for your additions! Now the PR is complete and I'll merge it to the default branch.

Many thanks! In case you find more things to improve, don't hesitate to open an issue or pull request. 🙂

@tomschr tomschr merged commit b5317af into python-semver:master Jul 4, 2022
tomschr pushed a commit to tomschr/python-semver that referenced this pull request Oct 4, 2022
)

* Add tests for new default equality match behavior
* Change documentation and add changelog
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.

2 participants