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

Mismatched comparison operations for Specifiers #462

Closed
jbylund opened this issue Oct 11, 2021 · 1 comment · Fixed by #464
Closed

Mismatched comparison operations for Specifiers #462

jbylund opened this issue Oct 11, 2021 · 1 comment · Fixed by #464

Comments

@jbylund
Copy link
Contributor

jbylund commented Oct 11, 2021

I just found this behavior a little surprising, and I feel like I'd be prone to make the assumption that a == b => not(a != b), doesn't seem to be mentioned in the docs: https://packaging.pypa.io/en/latest/specifiers.html

In [9]: lt4 = packaging.specifiers.Specifier("<4")

In [10]: lt4point0 = packaging.specifiers.Specifier("<4.0")

In [11]: lt4 == lt4point0
Out[11]: True

In [12]: lt4 != lt4point0
Out[12]: True
@pradyunsg pradyunsg changed the title Possibly Confusing Specifier Behavior? Mismatched comparison operations for Specifiers Oct 11, 2021
@pradyunsg
Copy link
Member

pradyunsg commented Oct 11, 2021

return self._canonical_spec == other._canonical_spec

return self._spec != other._spec

Seems like a relatively simple fix -- both should use _canonical_spec. :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants