Skip to content
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

Equality is missing in Requirement contrast to what is mentioned in the documentation #588

Closed
gmichaeljaison opened this issue Aug 29, 2022 · 3 comments

Comments

@gmichaeljaison
Copy link

The documentation mentions and shows example of simple equality operations. But it does not work with installed packaging package.

Expected:

# You can do simple comparisons between requirement objects:
>>> Requirement("packaging") == Requirement("packaging")
True
>>> # You can also perform simple comparisons between sets of requirements:
>>> requirements1 = {Requirement("packaging"), Requirement("pip")}
>>> requirements2 = {Requirement("pip"), Requirement("packaging")}
>>> requirements1 == requirements2

Actual:

>>> Requirement("packaging") == Requirement("packaging")
False

Version:
Python 3.9
packaging 21.3

Documentation: https://packaging.pypa.io/en/latest/requirements.html

@pradyunsg
Copy link
Member

pradyunsg commented Aug 30, 2022

We have tests for this, and (I’m not a 100% sure about this next bit) that code sample should be getting tested via doctest as well.

def test_equal_reqs_equal_hashes(self, dep1, dep2):

@uranusjr
Copy link
Member

This was already implemented in #499 but not yet released. The documentation is not wrong either since the link is latest (which reflects the main branch); documentation for the stable version does not contain the example.

@pradyunsg
Copy link
Member

Indeed, cross linking to #569 and closing then. :)

@pradyunsg pradyunsg removed the bug label Aug 31, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants